@fluid-experimental/ink 3.4.0 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/ink.d.ts +0 -24
- package/dist/ink.d.ts.map +1 -1
- package/dist/ink.js +0 -24
- package/dist/ink.js.map +1 -1
- package/dist/inkFactory.d.ts +0 -12
- package/dist/inkFactory.d.ts.map +1 -1
- package/dist/inkFactory.js +0 -12
- package/dist/inkFactory.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/lib/ink.d.ts +0 -24
- package/lib/ink.d.ts.map +1 -1
- package/lib/ink.js +0 -24
- package/lib/ink.js.map +1 -1
- package/lib/inkFactory.d.ts +0 -12
- package/lib/inkFactory.d.ts.map +1 -1
- package/lib/inkFactory.js +0 -12
- package/lib/inkFactory.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/package.json +11 -11
- package/src/ink.ts +0 -24
- package/src/inkFactory.ts +0 -12
- package/src/packageVersion.ts +1 -1
package/CHANGELOG.md
CHANGED
package/dist/ink.d.ts
CHANGED
|
@@ -95,33 +95,12 @@ export declare class Ink extends SharedObject<IInkEvents> implements IInk {
|
|
|
95
95
|
* @param id - Unique ID for the Ink
|
|
96
96
|
*/
|
|
97
97
|
constructor(runtime: IFluidDataStoreRuntime, id: string, attributes: IChannelAttributes);
|
|
98
|
-
/**
|
|
99
|
-
* {@inheritDoc IInk.createStroke}
|
|
100
|
-
*/
|
|
101
98
|
createStroke(pen: IPen): IInkStroke;
|
|
102
|
-
/**
|
|
103
|
-
* {@inheritDoc IInk.appendPointToStroke}
|
|
104
|
-
*/
|
|
105
99
|
appendPointToStroke(point: IInkPoint, id: string): IInkStroke;
|
|
106
|
-
/**
|
|
107
|
-
* {@inheritDoc IInk.clear}
|
|
108
|
-
*/
|
|
109
100
|
clear(): void;
|
|
110
|
-
/**
|
|
111
|
-
* {@inheritDoc IInk.getStrokes}
|
|
112
|
-
*/
|
|
113
101
|
getStrokes(): IInkStroke[];
|
|
114
|
-
/**
|
|
115
|
-
* {@inheritDoc IInk.getStroke}
|
|
116
|
-
*/
|
|
117
102
|
getStroke(key: string): IInkStroke;
|
|
118
|
-
/**
|
|
119
|
-
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}
|
|
120
|
-
*/
|
|
121
103
|
protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats;
|
|
122
|
-
/**
|
|
123
|
-
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
|
|
124
|
-
*/
|
|
125
104
|
protected loadCore(storage: IChannelStorageService): Promise<void>;
|
|
126
105
|
protected processMessagesCore(messagesCollection: IRuntimeMessageCollection): void;
|
|
127
106
|
/**
|
|
@@ -134,9 +113,6 @@ export declare class Ink extends SharedObject<IInkEvents> implements IInk {
|
|
|
134
113
|
* @param local - Whether or not the message was sent by the local client.
|
|
135
114
|
*/
|
|
136
115
|
private processMessage;
|
|
137
|
-
/**
|
|
138
|
-
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}
|
|
139
|
-
*/
|
|
140
116
|
protected onDisconnect(): void;
|
|
141
117
|
/**
|
|
142
118
|
* Update the model for a clear operation.
|
package/dist/ink.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ink.d.ts","sourceRoot":"","sources":["../src/ink.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,gDAAgD,CAAC;AAGxD,OAAO,KAAK,EACX,qBAAqB,EACrB,yBAAyB,EAGzB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EACN,KAAK,gBAAgB,EACrB,YAAY,EAEZ,MAAM,6CAA6C,CAAC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,MAAM,CAAC,OAAO,EAAE,sBAAsB,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,GAAG;IAIvE;;;OAGG;WACW,UAAU,IAAI,UAAU;IAItC;;OAEG;IACH,OAAO,CAAC,OAAO,CAA0B;IAEzC;;;;OAIG;gBACS,OAAO,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB;IAIhF,YAAY,CAAC,GAAG,EAAE,IAAI,GAAG,UAAU;IAWnC,mBAAmB,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,GAAG,UAAU;IAU7D,KAAK,IAAI,IAAI;IASb,UAAU,IAAI,UAAU,EAAE;IAI1B,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU;IAIzC,SAAS,CAAC,aAAa,CAAC,UAAU,EAAE,gBAAgB,GAAG,qBAAqB;cAK5D,QAAQ,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;cAKrD,mBAAmB,CAAC,kBAAkB,EAAE,yBAAyB,GAAG,IAAI;IAO3F;;;;;;;;OAQG;IACH,OAAO,CAAC,cAAc;IA2BtB,SAAS,CAAC,YAAY,IAAI,IAAI;IAI9B;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAK7B;;;;OAIG;IACH,OAAO,CAAC,4BAA4B;IAWpC;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IAU9B,SAAS,CAAC,cAAc,IAAI,IAAI;CAGhC"}
|
package/dist/ink.js
CHANGED
|
@@ -109,9 +109,6 @@ class Ink extends internal_3.SharedObject {
|
|
|
109
109
|
constructor(runtime, id, attributes) {
|
|
110
110
|
super(id, runtime, attributes, "fluid_ink_");
|
|
111
111
|
}
|
|
112
|
-
/**
|
|
113
|
-
* {@inheritDoc IInk.createStroke}
|
|
114
|
-
*/
|
|
115
112
|
createStroke(pen) {
|
|
116
113
|
const createStrokeOperation = {
|
|
117
114
|
id: (0, uuid_1.v4)(),
|
|
@@ -122,9 +119,6 @@ class Ink extends internal_3.SharedObject {
|
|
|
122
119
|
this.submitLocalMessage(createStrokeOperation, undefined);
|
|
123
120
|
return this.executeCreateStrokeOperation(createStrokeOperation);
|
|
124
121
|
}
|
|
125
|
-
/**
|
|
126
|
-
* {@inheritDoc IInk.appendPointToStroke}
|
|
127
|
-
*/
|
|
128
122
|
appendPointToStroke(point, id) {
|
|
129
123
|
const stylusOperation = {
|
|
130
124
|
id,
|
|
@@ -134,9 +128,6 @@ class Ink extends internal_3.SharedObject {
|
|
|
134
128
|
this.submitLocalMessage(stylusOperation, undefined);
|
|
135
129
|
return this.executeStylusOperation(stylusOperation);
|
|
136
130
|
}
|
|
137
|
-
/**
|
|
138
|
-
* {@inheritDoc IInk.clear}
|
|
139
|
-
*/
|
|
140
131
|
clear() {
|
|
141
132
|
const clearOperation = {
|
|
142
133
|
time: Date.now(),
|
|
@@ -145,28 +136,16 @@ class Ink extends internal_3.SharedObject {
|
|
|
145
136
|
this.submitLocalMessage(clearOperation, undefined);
|
|
146
137
|
this.executeClearOperation(clearOperation);
|
|
147
138
|
}
|
|
148
|
-
/**
|
|
149
|
-
* {@inheritDoc IInk.getStrokes}
|
|
150
|
-
*/
|
|
151
139
|
getStrokes() {
|
|
152
140
|
return this.inkData.getStrokes();
|
|
153
141
|
}
|
|
154
|
-
/**
|
|
155
|
-
* {@inheritDoc IInk.getStroke}
|
|
156
|
-
*/
|
|
157
142
|
getStroke(key) {
|
|
158
143
|
return this.inkData.getStroke(key);
|
|
159
144
|
}
|
|
160
|
-
/**
|
|
161
|
-
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}
|
|
162
|
-
*/
|
|
163
145
|
summarizeCore(serializer) {
|
|
164
146
|
const blobContent = JSON.stringify(this.inkData.getSerializable());
|
|
165
147
|
return (0, internal_3.createSingleBlobSummary)(snapshotFileName, blobContent);
|
|
166
148
|
}
|
|
167
|
-
/**
|
|
168
|
-
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
|
|
169
|
-
*/
|
|
170
149
|
async loadCore(storage) {
|
|
171
150
|
const content = await (0, internal_2.readAndParse)(storage, snapshotFileName);
|
|
172
151
|
this.inkData = new snapshot_js_1.InkData(content);
|
|
@@ -208,9 +187,6 @@ class Ink extends internal_3.SharedObject {
|
|
|
208
187
|
}
|
|
209
188
|
}
|
|
210
189
|
}
|
|
211
|
-
/**
|
|
212
|
-
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}
|
|
213
|
-
*/
|
|
214
190
|
onDisconnect() {
|
|
215
191
|
return;
|
|
216
192
|
}
|
package/dist/ink.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ink.js","sourceRoot":"","sources":["../src/ink.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,0EAA0E;AAC1E,oEAAqE;AAOrE,0EAIqD;AACrD,+BAAkC;AAElC,mDAA6C;AAY7C,+CAA+D;AAE/D;;GAEG;AACH,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AACH,MAAa,GAAI,SAAQ,uBAAwB;IAChD;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,OAA+B,EAAE,EAAW;QAChE,OAAO,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,0BAAU,CAAC,IAAI,CAAQ,CAAC;IAC1D,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,UAAU;QACvB,OAAO,IAAI,0BAAU,EAAE,CAAC;IACzB,CAAC;IAED;;OAEG;IACK,OAAO,GAAY,IAAI,qBAAO,EAAE,CAAC;IAEzC;;;;OAIG;IACH,YAAY,OAA+B,EAAE,EAAU,EAAE,UAA8B;QACtF,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;IAC9C,CAAC;IAED;;OAEG;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QACvD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACrB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAC/B,CAAC;IAED;;;;OAIG;IACK,4BAA4B,CAAC,SAAiC;QACrE,MAAM,MAAM,GAAe;YAC1B,EAAE,EAAE,SAAS,CAAC,EAAE;YAChB,MAAM,EAAE,EAAE;YACV,GAAG,EAAE,SAAS,CAAC,GAAG;SAClB,CAAC;QACF,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAC/B,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;QACrC,OAAO,MAAM,CAAC;IACf,CAAC;IAED;;;;OAIG;IACK,sBAAsB,CAAC,SAA2B;QACzD,uGAAuG;QACvG,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;QAC5C,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YAC1B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YACpC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAChC,CAAC;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IAES,cAAc;QACvB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACpC,CAAC;CACD;AAnMD,kBAmMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { MessageType } from \"@fluidframework/driver-definitions/internal\";\nimport { readAndParse } from \"@fluidframework/driver-utils/internal\";\nimport type {\n\tISummaryTreeWithStats,\n\tIRuntimeMessageCollection,\n\tIRuntimeMessagesContent,\n\tISequencedMessageEnvelope,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\ttype IFluidSerializer,\n\tSharedObject,\n\tcreateSingleBlobSummary,\n} from \"@fluidframework/shared-object-base/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { InkFactory } from \"./inkFactory.js\";\nimport type {\n\tIClearOperation,\n\tICreateStrokeOperation,\n\tIInk,\n\tIInkEvents,\n\tIInkOperation,\n\tIInkPoint,\n\tIInkStroke,\n\tIPen,\n\tIStylusOperation,\n} from \"./interfaces.js\";\nimport { type ISerializableInk, InkData } from \"./snapshot.js\";\n\n/**\n * Filename where the snapshot is stored.\n */\nconst snapshotFileName = \"header\";\n\n/**\n * `Ink` is a shared object which holds a collection of ink strokes.\n *\n * @remarks\n * ### Creation and setup\n *\n * To create an `Ink` object, call the static `create` method:\n *\n * ```typescript\n * const ink = Ink.create(this.runtime, id);\n * ```\n *\n * You'll also need an `IPen` that will describe the style of your stroke:\n *\n * ```typescript\n * this.currentPen = {\n * color: { r: 0, g: 161 / 255, b: 241 / 255, a: 0 },\n * thickness: 7,\n * };\n * ```\n *\n * ### Usage\n *\n * Once the `Ink` object is created, you can add and update ink strokes using `createStroke` and\n * `appendPointToStroke`. Most likely you'll want to do this in response to incoming Pointer Events:\n *\n * ```typescript\n * private handlePointerDown(e: PointerEvent) {\n * const newStroke = ink.createStroke(this.currentPen);\n * this.currentStrokeId = newStroke.id;\n * handlePointerMotion(e);\n * }\n *\n * private handlePointerMotion(e: PointerEvent) {\n * const inkPoint = {\n * x: e.clientX,\n * y: e.clientY,\n * time: Date.now(),\n * pressure: e.pressure,\n * };\n * ink.appendPointToStroke(inkPoint, this.currentStrokeId);\n * }\n *\n * canvas.addEventListener(\"pointerdown\", this.handlePointerDown);\n * canvas.addEventListener(\"pointermove\", this.handlePointerMotion);\n * canvas.addEventListener(\"pointerup\", this.handlePointerMotion);\n * ```\n *\n * You can also clear all the ink with `clear`:\n *\n * ```typescript\n * ink.clear();\n * ```\n *\n * To observe and react to changes to the ink from both your own modifications as well as remote participants,\n * you can listen to the `\"createStroke\"`, `\"stylus\"` and `\"clear\"` events. Since you don't need to render anything\n * yet when a stroke is first created, registering for `\"createStroke\"` may not be necessary.\n *\n * ```typescript\n * ink.on(\"stylus\", this.renderStylusUpdate.bind(this));\n * ink.on(\"clear\", this.renderClear.bind(this));\n * ```\n * @sealed\n * @internal\n */\nexport class Ink extends SharedObject<IInkEvents> implements IInk {\n\t/**\n\t * Create a new Ink.\n\t * @param runtime - Data Store runtime the new Ink belongs to\n\t * @param id - Optional name of the Ink; will be assigned a unique ID if not provided\n\t * @returns Newly create Ink object (but not attached yet)\n\t */\n\tpublic static create(runtime: IFluidDataStoreRuntime, id?: string): Ink {\n\t\treturn runtime.createChannel(id, InkFactory.Type) as Ink;\n\t}\n\n\t/**\n\t * Get a factory for Ink to register with the data store.\n\t * @returns A factory that creates and loads Ink\n\t */\n\tpublic static getFactory(): InkFactory {\n\t\treturn new InkFactory();\n\t}\n\n\t/**\n\t * The current ink snapshot.\n\t */\n\tprivate inkData: InkData = new InkData();\n\n\t/**\n\t * Create a new Ink.\n\t * @param runtime - The runtime the Ink will be associated with\n\t * @param id - Unique ID for the Ink\n\t */\n\tconstructor(runtime: IFluidDataStoreRuntime, id: string, attributes: IChannelAttributes) {\n\t\tsuper(id, runtime, attributes, \"fluid_ink_\");\n\t}\n\n\t/**\n\t * {@inheritDoc IInk.createStroke}\n\t */\n\tpublic createStroke(pen: IPen): IInkStroke {\n\t\tconst createStrokeOperation: ICreateStrokeOperation = {\n\t\t\tid: uuid(),\n\t\t\tpen,\n\t\t\ttime: Date.now(),\n\t\t\ttype: \"createStroke\",\n\t\t};\n\t\tthis.submitLocalMessage(createStrokeOperation, undefined);\n\t\treturn this.executeCreateStrokeOperation(createStrokeOperation);\n\t}\n\n\t/**\n\t * {@inheritDoc IInk.appendPointToStroke}\n\t */\n\tpublic appendPointToStroke(point: IInkPoint, id: string): IInkStroke {\n\t\tconst stylusOperation: IStylusOperation = {\n\t\t\tid,\n\t\t\tpoint,\n\t\t\ttype: \"stylus\",\n\t\t};\n\t\tthis.submitLocalMessage(stylusOperation, undefined);\n\t\treturn this.executeStylusOperation(stylusOperation);\n\t}\n\n\t/**\n\t * {@inheritDoc IInk.clear}\n\t */\n\tpublic clear(): void {\n\t\tconst clearOperation: IClearOperation = {\n\t\t\ttime: Date.now(),\n\t\t\ttype: \"clear\",\n\t\t};\n\t\tthis.submitLocalMessage(clearOperation, undefined);\n\t\tthis.executeClearOperation(clearOperation);\n\t}\n\n\t/**\n\t * {@inheritDoc IInk.getStrokes}\n\t */\n\tpublic getStrokes(): IInkStroke[] {\n\t\treturn this.inkData.getStrokes();\n\t}\n\n\t/**\n\t * {@inheritDoc IInk.getStroke}\n\t */\n\tpublic getStroke(key: string): IInkStroke {\n\t\treturn this.inkData.getStroke(key);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}\n\t */\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\tconst blobContent = JSON.stringify(this.inkData.getSerializable());\n\t\treturn createSingleBlobSummary(snapshotFileName, blobContent);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst content = await readAndParse<ISerializableInk>(storage, snapshotFileName);\n\t\tthis.inkData = new InkData(content);\n\t}\n\n\tprotected override processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, local, messagesContent } = messagesCollection;\n\t\tfor (const messageContent of messagesContent) {\n\t\t\tthis.processMessage(envelope, messageContent, local);\n\t\t}\n\t}\n\n\t/**\n\t * Process an ink operation message.\n\t *\n\t * @param messageEnvelope - The message envelope.\n\t * @param messageContent - The runtime message content containing the contents, i.e., payload and the\n\t * local op metadata. 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 * @param local - Whether or not the message was sent by the local client.\n\t */\n\tprivate processMessage(\n\t\tmessageEnvelope: ISequencedMessageEnvelope,\n\t\tmessageContent: IRuntimeMessagesContent,\n\t\tlocal: boolean,\n\t): void {\n\t\tif (messageEnvelope.type === MessageType.Operation && !local) {\n\t\t\tconst operation = messageContent.contents as IInkOperation;\n\t\t\tswitch (operation.type) {\n\t\t\t\tcase \"clear\": {\n\t\t\t\t\tthis.executeClearOperation(operation);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"createStroke\": {\n\t\t\t\t\tthis.executeCreateStrokeOperation(operation);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"stylus\": {\n\t\t\t\t\tthis.executeStylusOperation(operation);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}\n\t */\n\tprotected onDisconnect(): void {\n\t\treturn;\n\t}\n\n\t/**\n\t * Update the model for a clear operation.\n\t * @param operation - The operation object\n\t */\n\tprivate executeClearOperation(operation: IClearOperation): void {\n\t\tthis.inkData.clear();\n\t\tthis.emit(\"clear\", operation);\n\t}\n\n\t/**\n\t * Update the model for a create stroke operation.\n\t * @param operation - The operation object\n\t * @returns The stroke that was created\n\t */\n\tprivate executeCreateStrokeOperation(operation: ICreateStrokeOperation): IInkStroke {\n\t\tconst stroke: IInkStroke = {\n\t\t\tid: operation.id,\n\t\t\tpoints: [],\n\t\t\tpen: operation.pen,\n\t\t};\n\t\tthis.inkData.addStroke(stroke);\n\t\tthis.emit(\"createStroke\", operation);\n\t\treturn stroke;\n\t}\n\n\t/**\n\t * Update the model for a stylus operation. These represent updates to an existing stroke.\n\t * @param operation - The operation object\n\t * @returns The stroke that was updated\n\t */\n\tprivate executeStylusOperation(operation: IStylusOperation): IInkStroke {\n\t\t// Need to make sure the stroke is still there (hasn't been cleared) before appending the down/move/up.\n\t\tconst stroke = this.getStroke(operation.id);\n\t\tif (stroke !== undefined) {\n\t\t\tstroke.points.push(operation.point);\n\t\t\tthis.emit(\"stylus\", operation);\n\t\t}\n\t\treturn stroke;\n\t}\n\n\tprotected applyStashedOp(): void {\n\t\tthrow new Error(\"not implemented\");\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ink.js","sourceRoot":"","sources":["../src/ink.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,0EAA0E;AAC1E,oEAAqE;AAOrE,0EAIqD;AACrD,+BAAkC;AAElC,mDAA6C;AAY7C,+CAA+D;AAE/D;;GAEG;AACH,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AACH,MAAa,GAAI,SAAQ,uBAAwB;IAChD;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,OAA+B,EAAE,EAAW;QAChE,OAAO,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,0BAAU,CAAC,IAAI,CAAQ,CAAC;IAC1D,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,UAAU;QACvB,OAAO,IAAI,0BAAU,EAAE,CAAC;IACzB,CAAC;IAED;;OAEG;IACK,OAAO,GAAY,IAAI,qBAAO,EAAE,CAAC;IAEzC;;;;OAIG;IACH,YAAY,OAA+B,EAAE,EAAU,EAAE,UAA8B;QACtF,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;IAC9C,CAAC;IAEM,YAAY,CAAC,GAAS;QAC5B,MAAM,qBAAqB,GAA2B;YACrD,EAAE,EAAE,IAAA,SAAI,GAAE;YACV,GAAG;YACH,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE;YAChB,IAAI,EAAE,cAAc;SACpB,CAAC;QACF,IAAI,CAAC,kBAAkB,CAAC,qBAAqB,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QACF,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAC/B,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;QACrC,OAAO,MAAM,CAAC;IACf,CAAC;IAED;;;;OAIG;IACK,sBAAsB,CAAC,SAA2B;QACzD,uGAAuG;QACvG,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;QAC5C,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YAC1B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YACpC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAChC,CAAC;QACD,OAAO,MAAM,CAAC;IACf,CAAC;IAES,cAAc;QACvB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACpC,CAAC;CACD;AA3KD,kBA2KC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { MessageType } from \"@fluidframework/driver-definitions/internal\";\nimport { readAndParse } from \"@fluidframework/driver-utils/internal\";\nimport type {\n\tISummaryTreeWithStats,\n\tIRuntimeMessageCollection,\n\tIRuntimeMessagesContent,\n\tISequencedMessageEnvelope,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\ttype IFluidSerializer,\n\tSharedObject,\n\tcreateSingleBlobSummary,\n} from \"@fluidframework/shared-object-base/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { InkFactory } from \"./inkFactory.js\";\nimport type {\n\tIClearOperation,\n\tICreateStrokeOperation,\n\tIInk,\n\tIInkEvents,\n\tIInkOperation,\n\tIInkPoint,\n\tIInkStroke,\n\tIPen,\n\tIStylusOperation,\n} from \"./interfaces.js\";\nimport { type ISerializableInk, InkData } from \"./snapshot.js\";\n\n/**\n * Filename where the snapshot is stored.\n */\nconst snapshotFileName = \"header\";\n\n/**\n * `Ink` is a shared object which holds a collection of ink strokes.\n *\n * @remarks\n * ### Creation and setup\n *\n * To create an `Ink` object, call the static `create` method:\n *\n * ```typescript\n * const ink = Ink.create(this.runtime, id);\n * ```\n *\n * You'll also need an `IPen` that will describe the style of your stroke:\n *\n * ```typescript\n * this.currentPen = {\n * color: { r: 0, g: 161 / 255, b: 241 / 255, a: 0 },\n * thickness: 7,\n * };\n * ```\n *\n * ### Usage\n *\n * Once the `Ink` object is created, you can add and update ink strokes using `createStroke` and\n * `appendPointToStroke`. Most likely you'll want to do this in response to incoming Pointer Events:\n *\n * ```typescript\n * private handlePointerDown(e: PointerEvent) {\n * const newStroke = ink.createStroke(this.currentPen);\n * this.currentStrokeId = newStroke.id;\n * handlePointerMotion(e);\n * }\n *\n * private handlePointerMotion(e: PointerEvent) {\n * const inkPoint = {\n * x: e.clientX,\n * y: e.clientY,\n * time: Date.now(),\n * pressure: e.pressure,\n * };\n * ink.appendPointToStroke(inkPoint, this.currentStrokeId);\n * }\n *\n * canvas.addEventListener(\"pointerdown\", this.handlePointerDown);\n * canvas.addEventListener(\"pointermove\", this.handlePointerMotion);\n * canvas.addEventListener(\"pointerup\", this.handlePointerMotion);\n * ```\n *\n * You can also clear all the ink with `clear`:\n *\n * ```typescript\n * ink.clear();\n * ```\n *\n * To observe and react to changes to the ink from both your own modifications as well as remote participants,\n * you can listen to the `\"createStroke\"`, `\"stylus\"` and `\"clear\"` events. Since you don't need to render anything\n * yet when a stroke is first created, registering for `\"createStroke\"` may not be necessary.\n *\n * ```typescript\n * ink.on(\"stylus\", this.renderStylusUpdate.bind(this));\n * ink.on(\"clear\", this.renderClear.bind(this));\n * ```\n * @sealed\n * @internal\n */\nexport class Ink extends SharedObject<IInkEvents> implements IInk {\n\t/**\n\t * Create a new Ink.\n\t * @param runtime - Data Store runtime the new Ink belongs to\n\t * @param id - Optional name of the Ink; will be assigned a unique ID if not provided\n\t * @returns Newly create Ink object (but not attached yet)\n\t */\n\tpublic static create(runtime: IFluidDataStoreRuntime, id?: string): Ink {\n\t\treturn runtime.createChannel(id, InkFactory.Type) as Ink;\n\t}\n\n\t/**\n\t * Get a factory for Ink to register with the data store.\n\t * @returns A factory that creates and loads Ink\n\t */\n\tpublic static getFactory(): InkFactory {\n\t\treturn new InkFactory();\n\t}\n\n\t/**\n\t * The current ink snapshot.\n\t */\n\tprivate inkData: InkData = new InkData();\n\n\t/**\n\t * Create a new Ink.\n\t * @param runtime - The runtime the Ink will be associated with\n\t * @param id - Unique ID for the Ink\n\t */\n\tconstructor(runtime: IFluidDataStoreRuntime, id: string, attributes: IChannelAttributes) {\n\t\tsuper(id, runtime, attributes, \"fluid_ink_\");\n\t}\n\n\tpublic createStroke(pen: IPen): IInkStroke {\n\t\tconst createStrokeOperation: ICreateStrokeOperation = {\n\t\t\tid: uuid(),\n\t\t\tpen,\n\t\t\ttime: Date.now(),\n\t\t\ttype: \"createStroke\",\n\t\t};\n\t\tthis.submitLocalMessage(createStrokeOperation, undefined);\n\t\treturn this.executeCreateStrokeOperation(createStrokeOperation);\n\t}\n\n\tpublic appendPointToStroke(point: IInkPoint, id: string): IInkStroke {\n\t\tconst stylusOperation: IStylusOperation = {\n\t\t\tid,\n\t\t\tpoint,\n\t\t\ttype: \"stylus\",\n\t\t};\n\t\tthis.submitLocalMessage(stylusOperation, undefined);\n\t\treturn this.executeStylusOperation(stylusOperation);\n\t}\n\n\tpublic clear(): void {\n\t\tconst clearOperation: IClearOperation = {\n\t\t\ttime: Date.now(),\n\t\t\ttype: \"clear\",\n\t\t};\n\t\tthis.submitLocalMessage(clearOperation, undefined);\n\t\tthis.executeClearOperation(clearOperation);\n\t}\n\n\tpublic getStrokes(): IInkStroke[] {\n\t\treturn this.inkData.getStrokes();\n\t}\n\n\tpublic getStroke(key: string): IInkStroke {\n\t\treturn this.inkData.getStroke(key);\n\t}\n\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\tconst blobContent = JSON.stringify(this.inkData.getSerializable());\n\t\treturn createSingleBlobSummary(snapshotFileName, blobContent);\n\t}\n\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst content = await readAndParse<ISerializableInk>(storage, snapshotFileName);\n\t\tthis.inkData = new InkData(content);\n\t}\n\n\tprotected override processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, local, messagesContent } = messagesCollection;\n\t\tfor (const messageContent of messagesContent) {\n\t\t\tthis.processMessage(envelope, messageContent, local);\n\t\t}\n\t}\n\n\t/**\n\t * Process an ink operation message.\n\t *\n\t * @param messageEnvelope - The message envelope.\n\t * @param messageContent - The runtime message content containing the contents, i.e., payload and the\n\t * local op metadata. 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 * @param local - Whether or not the message was sent by the local client.\n\t */\n\tprivate processMessage(\n\t\tmessageEnvelope: ISequencedMessageEnvelope,\n\t\tmessageContent: IRuntimeMessagesContent,\n\t\tlocal: boolean,\n\t): void {\n\t\tif (messageEnvelope.type === MessageType.Operation && !local) {\n\t\t\tconst operation = messageContent.contents as IInkOperation;\n\t\t\tswitch (operation.type) {\n\t\t\t\tcase \"clear\": {\n\t\t\t\t\tthis.executeClearOperation(operation);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"createStroke\": {\n\t\t\t\t\tthis.executeCreateStrokeOperation(operation);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"stylus\": {\n\t\t\t\t\tthis.executeStylusOperation(operation);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected onDisconnect(): void {\n\t\treturn;\n\t}\n\n\t/**\n\t * Update the model for a clear operation.\n\t * @param operation - The operation object\n\t */\n\tprivate executeClearOperation(operation: IClearOperation): void {\n\t\tthis.inkData.clear();\n\t\tthis.emit(\"clear\", operation);\n\t}\n\n\t/**\n\t * Update the model for a create stroke operation.\n\t * @param operation - The operation object\n\t * @returns The stroke that was created\n\t */\n\tprivate executeCreateStrokeOperation(operation: ICreateStrokeOperation): IInkStroke {\n\t\tconst stroke: IInkStroke = {\n\t\t\tid: operation.id,\n\t\t\tpoints: [],\n\t\t\tpen: operation.pen,\n\t\t};\n\t\tthis.inkData.addStroke(stroke);\n\t\tthis.emit(\"createStroke\", operation);\n\t\treturn stroke;\n\t}\n\n\t/**\n\t * Update the model for a stylus operation. These represent updates to an existing stroke.\n\t * @param operation - The operation object\n\t * @returns The stroke that was updated\n\t */\n\tprivate executeStylusOperation(operation: IStylusOperation): IInkStroke {\n\t\t// Need to make sure the stroke is still there (hasn't been cleared) before appending the down/move/up.\n\t\tconst stroke = this.getStroke(operation.id);\n\t\tif (stroke !== undefined) {\n\t\t\tstroke.points.push(operation.point);\n\t\t\tthis.emit(\"stylus\", operation);\n\t\t}\n\t\treturn stroke;\n\t}\n\n\tprotected applyStashedOp(): void {\n\t\tthrow new Error(\"not implemented\");\n\t}\n}\n"]}
|
package/dist/inkFactory.d.ts
CHANGED
|
@@ -18,21 +18,9 @@ export declare class InkFactory implements IChannelFactory {
|
|
|
18
18
|
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}
|
|
19
19
|
*/
|
|
20
20
|
static readonly Attributes: IChannelAttributes;
|
|
21
|
-
/**
|
|
22
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory."type"}
|
|
23
|
-
*/
|
|
24
21
|
get type(): string;
|
|
25
|
-
/**
|
|
26
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}
|
|
27
|
-
*/
|
|
28
22
|
get attributes(): IChannelAttributes;
|
|
29
|
-
/**
|
|
30
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
|
|
31
|
-
*/
|
|
32
23
|
load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, attributes: IChannelAttributes): Promise<ISharedObject>;
|
|
33
|
-
/**
|
|
34
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}
|
|
35
|
-
*/
|
|
36
24
|
create(runtime: IFluidDataStoreRuntime, id: string): ISharedObject;
|
|
37
25
|
}
|
|
38
26
|
//# sourceMappingURL=inkFactory.d.ts.map
|
package/dist/inkFactory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inkFactory.d.ts","sourceRoot":"","sources":["../src/inkFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,MAAM,gDAAgD,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAKjF;;;;GAIG;AACH,qBAAa,UAAW,YAAW,eAAe;IACjD;;OAEG;IAIH,OAAc,IAAI,SAA2C;IAE7D;;OAEG;IACH,gBAAuB,UAAU,EAAE,kBAAkB,CAInD;IAEF
|
|
1
|
+
{"version":3,"file":"inkFactory.d.ts","sourceRoot":"","sources":["../src/inkFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,MAAM,gDAAgD,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAKjF;;;;GAIG;AACH,qBAAa,UAAW,YAAW,eAAe;IACjD;;OAEG;IAIH,OAAc,IAAI,SAA2C;IAE7D;;OAEG;IACH,gBAAuB,UAAU,EAAE,kBAAkB,CAInD;IAEF,IAAW,IAAI,IAAI,MAAM,CAExB;IAED,IAAW,UAAU,IAAI,kBAAkB,CAE1C;IAEY,IAAI,CAChB,OAAO,EAAE,sBAAsB,EAC/B,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EAAE,kBAAkB,GAC5B,OAAO,CAAC,aAAa,CAAC;IAOlB,MAAM,CAAC,OAAO,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,GAAG,aAAa;CAMzE"}
|
package/dist/inkFactory.js
CHANGED
|
@@ -28,29 +28,17 @@ class InkFactory {
|
|
|
28
28
|
snapshotFormatVersion: "0.2",
|
|
29
29
|
packageVersion: packageVersion_js_1.pkgVersion,
|
|
30
30
|
};
|
|
31
|
-
/**
|
|
32
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory."type"}
|
|
33
|
-
*/
|
|
34
31
|
get type() {
|
|
35
32
|
return InkFactory.Type;
|
|
36
33
|
}
|
|
37
|
-
/**
|
|
38
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}
|
|
39
|
-
*/
|
|
40
34
|
get attributes() {
|
|
41
35
|
return InkFactory.Attributes;
|
|
42
36
|
}
|
|
43
|
-
/**
|
|
44
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
|
|
45
|
-
*/
|
|
46
37
|
async load(runtime, id, services, attributes) {
|
|
47
38
|
const ink = new ink_js_1.Ink(runtime, id, attributes);
|
|
48
39
|
await ink.load(services);
|
|
49
40
|
return ink;
|
|
50
41
|
}
|
|
51
|
-
/**
|
|
52
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}
|
|
53
|
-
*/
|
|
54
42
|
create(runtime, id) {
|
|
55
43
|
const ink = new ink_js_1.Ink(runtime, id, InkFactory.Attributes);
|
|
56
44
|
ink.initializeLocal();
|
package/dist/inkFactory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inkFactory.js","sourceRoot":"","sources":["../src/inkFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAUH,qCAA+B;AAC/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AG,CAAC,eAAe,EAAE,CAAC;QAEtB,OAAO,GAAG,CAAC;IACZ,CAAC;;AA3CF,gCA4CC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIChannelAttributes,\n\tIChannelFactory,\n\tIFluidDataStoreRuntime,\n\tIChannelServices,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type { ISharedObject } from \"@fluidframework/shared-object-base/internal\";\n\nimport { Ink } from \"./ink.js\";\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * Factory for Ink.\n * @sealed\n * @internal\n */\nexport class InkFactory implements IChannelFactory {\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t */\n\t// New type string, to be activated once the migration has been fully shipped dark and is safe to flip.\n\t// See LegacyTypeAwareRegistry in packages/runtime/datastore/src/dataStoreRuntime.ts.\n\t// public static Type = \"ink\";\n\tpublic static Type = \"https://graph.microsoft.com/types/ink\";\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t */\n\tpublic static readonly Attributes: IChannelAttributes = {\n\t\ttype: InkFactory.Type,\n\t\tsnapshotFormatVersion: \"0.2\",\n\t\tpackageVersion: pkgVersion,\n\t};\n\n\tpublic get type(): string {\n\t\treturn InkFactory.Type;\n\t}\n\n\tpublic get attributes(): IChannelAttributes {\n\t\treturn InkFactory.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<ISharedObject> {\n\t\tconst ink = new Ink(runtime, id, attributes);\n\t\tawait ink.load(services);\n\n\t\treturn ink;\n\t}\n\n\tpublic create(runtime: IFluidDataStoreRuntime, id: string): ISharedObject {\n\t\tconst ink = new Ink(runtime, id, InkFactory.Attributes);\n\t\tink.initializeLocal();\n\n\t\treturn ink;\n\t}\n}\n"]}
|
package/dist/packageVersion.d.ts
CHANGED
package/dist/packageVersion.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluid-experimental/ink";
|
|
11
|
-
exports.pkgVersion = "3.
|
|
11
|
+
exports.pkgVersion = "3.6.0";
|
|
12
12
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,yBAAyB,CAAC;AACpC,QAAA,UAAU,GAAG,OAAO,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluid-experimental/ink\";\nexport const pkgVersion = \"3.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,yBAAyB,CAAC;AACpC,QAAA,UAAU,GAAG,OAAO,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluid-experimental/ink\";\nexport const pkgVersion = \"3.6.0\";\n"]}
|
package/lib/ink.d.ts
CHANGED
|
@@ -95,33 +95,12 @@ export declare class Ink extends SharedObject<IInkEvents> implements IInk {
|
|
|
95
95
|
* @param id - Unique ID for the Ink
|
|
96
96
|
*/
|
|
97
97
|
constructor(runtime: IFluidDataStoreRuntime, id: string, attributes: IChannelAttributes);
|
|
98
|
-
/**
|
|
99
|
-
* {@inheritDoc IInk.createStroke}
|
|
100
|
-
*/
|
|
101
98
|
createStroke(pen: IPen): IInkStroke;
|
|
102
|
-
/**
|
|
103
|
-
* {@inheritDoc IInk.appendPointToStroke}
|
|
104
|
-
*/
|
|
105
99
|
appendPointToStroke(point: IInkPoint, id: string): IInkStroke;
|
|
106
|
-
/**
|
|
107
|
-
* {@inheritDoc IInk.clear}
|
|
108
|
-
*/
|
|
109
100
|
clear(): void;
|
|
110
|
-
/**
|
|
111
|
-
* {@inheritDoc IInk.getStrokes}
|
|
112
|
-
*/
|
|
113
101
|
getStrokes(): IInkStroke[];
|
|
114
|
-
/**
|
|
115
|
-
* {@inheritDoc IInk.getStroke}
|
|
116
|
-
*/
|
|
117
102
|
getStroke(key: string): IInkStroke;
|
|
118
|
-
/**
|
|
119
|
-
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}
|
|
120
|
-
*/
|
|
121
103
|
protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats;
|
|
122
|
-
/**
|
|
123
|
-
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
|
|
124
|
-
*/
|
|
125
104
|
protected loadCore(storage: IChannelStorageService): Promise<void>;
|
|
126
105
|
protected processMessagesCore(messagesCollection: IRuntimeMessageCollection): void;
|
|
127
106
|
/**
|
|
@@ -134,9 +113,6 @@ export declare class Ink extends SharedObject<IInkEvents> implements IInk {
|
|
|
134
113
|
* @param local - Whether or not the message was sent by the local client.
|
|
135
114
|
*/
|
|
136
115
|
private processMessage;
|
|
137
|
-
/**
|
|
138
|
-
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}
|
|
139
|
-
*/
|
|
140
116
|
protected onDisconnect(): void;
|
|
141
117
|
/**
|
|
142
118
|
* Update the model for a clear operation.
|
package/lib/ink.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ink.d.ts","sourceRoot":"","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-106,9 +106,6 @@ export class Ink extends SharedObject {
|
|
|
106
106
|
constructor(runtime, id, attributes) {
|
|
107
107
|
super(id, runtime, attributes, "fluid_ink_");
|
|
108
108
|
}
|
|
109
|
-
/**
|
|
110
|
-
* {@inheritDoc IInk.createStroke}
|
|
111
|
-
*/
|
|
112
109
|
createStroke(pen) {
|
|
113
110
|
const createStrokeOperation = {
|
|
114
111
|
id: uuid(),
|
|
@@ -119,9 +116,6 @@ export class Ink extends SharedObject {
|
|
|
119
116
|
this.submitLocalMessage(createStrokeOperation, undefined);
|
|
120
117
|
return this.executeCreateStrokeOperation(createStrokeOperation);
|
|
121
118
|
}
|
|
122
|
-
/**
|
|
123
|
-
* {@inheritDoc IInk.appendPointToStroke}
|
|
124
|
-
*/
|
|
125
119
|
appendPointToStroke(point, id) {
|
|
126
120
|
const stylusOperation = {
|
|
127
121
|
id,
|
|
@@ -131,9 +125,6 @@ export class Ink extends SharedObject {
|
|
|
131
125
|
this.submitLocalMessage(stylusOperation, undefined);
|
|
132
126
|
return this.executeStylusOperation(stylusOperation);
|
|
133
127
|
}
|
|
134
|
-
/**
|
|
135
|
-
* {@inheritDoc IInk.clear}
|
|
136
|
-
*/
|
|
137
128
|
clear() {
|
|
138
129
|
const clearOperation = {
|
|
139
130
|
time: Date.now(),
|
|
@@ -142,28 +133,16 @@ export class Ink extends SharedObject {
|
|
|
142
133
|
this.submitLocalMessage(clearOperation, undefined);
|
|
143
134
|
this.executeClearOperation(clearOperation);
|
|
144
135
|
}
|
|
145
|
-
/**
|
|
146
|
-
* {@inheritDoc IInk.getStrokes}
|
|
147
|
-
*/
|
|
148
136
|
getStrokes() {
|
|
149
137
|
return this.inkData.getStrokes();
|
|
150
138
|
}
|
|
151
|
-
/**
|
|
152
|
-
* {@inheritDoc IInk.getStroke}
|
|
153
|
-
*/
|
|
154
139
|
getStroke(key) {
|
|
155
140
|
return this.inkData.getStroke(key);
|
|
156
141
|
}
|
|
157
|
-
/**
|
|
158
|
-
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}
|
|
159
|
-
*/
|
|
160
142
|
summarizeCore(serializer) {
|
|
161
143
|
const blobContent = JSON.stringify(this.inkData.getSerializable());
|
|
162
144
|
return createSingleBlobSummary(snapshotFileName, blobContent);
|
|
163
145
|
}
|
|
164
|
-
/**
|
|
165
|
-
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
|
|
166
|
-
*/
|
|
167
146
|
async loadCore(storage) {
|
|
168
147
|
const content = await readAndParse(storage, snapshotFileName);
|
|
169
148
|
this.inkData = new InkData(content);
|
|
@@ -205,9 +184,6 @@ export class Ink extends SharedObject {
|
|
|
205
184
|
}
|
|
206
185
|
}
|
|
207
186
|
}
|
|
208
|
-
/**
|
|
209
|
-
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}
|
|
210
|
-
*/
|
|
211
187
|
onDisconnect() {
|
|
212
188
|
return;
|
|
213
189
|
}
|
package/lib/ink.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ink.js","sourceRoot":"","sources":["../src/ink.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,WAAW,EAAE,MAAM,6CAA6C,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAOrE,OAAO,EAEN,YAAY,EACZ,uBAAuB,GACvB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAY7C,OAAO,EAAyB,OAAO,EAAE,MAAM,eAAe,CAAC;AAE/D;;GAEG;AACH,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AACH,MAAM,OAAO,GAAI,SAAQ,YAAwB;IAChD;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IAES,cAAc;QACvB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACpC,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { MessageType } from \"@fluidframework/driver-definitions/internal\";\nimport { readAndParse } from \"@fluidframework/driver-utils/internal\";\nimport type {\n\tISummaryTreeWithStats,\n\tIRuntimeMessageCollection,\n\tIRuntimeMessagesContent,\n\tISequencedMessageEnvelope,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\ttype IFluidSerializer,\n\tSharedObject,\n\tcreateSingleBlobSummary,\n} from \"@fluidframework/shared-object-base/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { InkFactory } from \"./inkFactory.js\";\nimport type {\n\tIClearOperation,\n\tICreateStrokeOperation,\n\tIInk,\n\tIInkEvents,\n\tIInkOperation,\n\tIInkPoint,\n\tIInkStroke,\n\tIPen,\n\tIStylusOperation,\n} from \"./interfaces.js\";\nimport { type ISerializableInk, InkData } from \"./snapshot.js\";\n\n/**\n * Filename where the snapshot is stored.\n */\nconst snapshotFileName = \"header\";\n\n/**\n * `Ink` is a shared object which holds a collection of ink strokes.\n *\n * @remarks\n * ### Creation and setup\n *\n * To create an `Ink` object, call the static `create` method:\n *\n * ```typescript\n * const ink = Ink.create(this.runtime, id);\n * ```\n *\n * You'll also need an `IPen` that will describe the style of your stroke:\n *\n * ```typescript\n * this.currentPen = {\n * color: { r: 0, g: 161 / 255, b: 241 / 255, a: 0 },\n * thickness: 7,\n * };\n * ```\n *\n * ### Usage\n *\n * Once the `Ink` object is created, you can add and update ink strokes using `createStroke` and\n * `appendPointToStroke`. Most likely you'll want to do this in response to incoming Pointer Events:\n *\n * ```typescript\n * private handlePointerDown(e: PointerEvent) {\n * const newStroke = ink.createStroke(this.currentPen);\n * this.currentStrokeId = newStroke.id;\n * handlePointerMotion(e);\n * }\n *\n * private handlePointerMotion(e: PointerEvent) {\n * const inkPoint = {\n * x: e.clientX,\n * y: e.clientY,\n * time: Date.now(),\n * pressure: e.pressure,\n * };\n * ink.appendPointToStroke(inkPoint, this.currentStrokeId);\n * }\n *\n * canvas.addEventListener(\"pointerdown\", this.handlePointerDown);\n * canvas.addEventListener(\"pointermove\", this.handlePointerMotion);\n * canvas.addEventListener(\"pointerup\", this.handlePointerMotion);\n * ```\n *\n * You can also clear all the ink with `clear`:\n *\n * ```typescript\n * ink.clear();\n * ```\n *\n * To observe and react to changes to the ink from both your own modifications as well as remote participants,\n * you can listen to the `\"createStroke\"`, `\"stylus\"` and `\"clear\"` events. Since you don't need to render anything\n * yet when a stroke is first created, registering for `\"createStroke\"` may not be necessary.\n *\n * ```typescript\n * ink.on(\"stylus\", this.renderStylusUpdate.bind(this));\n * ink.on(\"clear\", this.renderClear.bind(this));\n * ```\n * @sealed\n * @internal\n */\nexport class Ink extends SharedObject<IInkEvents> implements IInk {\n\t/**\n\t * Create a new Ink.\n\t * @param runtime - Data Store runtime the new Ink belongs to\n\t * @param id - Optional name of the Ink; will be assigned a unique ID if not provided\n\t * @returns Newly create Ink object (but not attached yet)\n\t */\n\tpublic static create(runtime: IFluidDataStoreRuntime, id?: string): Ink {\n\t\treturn runtime.createChannel(id, InkFactory.Type) as Ink;\n\t}\n\n\t/**\n\t * Get a factory for Ink to register with the data store.\n\t * @returns A factory that creates and loads Ink\n\t */\n\tpublic static getFactory(): InkFactory {\n\t\treturn new InkFactory();\n\t}\n\n\t/**\n\t * The current ink snapshot.\n\t */\n\tprivate inkData: InkData = new InkData();\n\n\t/**\n\t * Create a new Ink.\n\t * @param runtime - The runtime the Ink will be associated with\n\t * @param id - Unique ID for the Ink\n\t */\n\tconstructor(runtime: IFluidDataStoreRuntime, id: string, attributes: IChannelAttributes) {\n\t\tsuper(id, runtime, attributes, \"fluid_ink_\");\n\t}\n\n\t/**\n\t * {@inheritDoc IInk.createStroke}\n\t */\n\tpublic createStroke(pen: IPen): IInkStroke {\n\t\tconst createStrokeOperation: ICreateStrokeOperation = {\n\t\t\tid: uuid(),\n\t\t\tpen,\n\t\t\ttime: Date.now(),\n\t\t\ttype: \"createStroke\",\n\t\t};\n\t\tthis.submitLocalMessage(createStrokeOperation, undefined);\n\t\treturn this.executeCreateStrokeOperation(createStrokeOperation);\n\t}\n\n\t/**\n\t * {@inheritDoc IInk.appendPointToStroke}\n\t */\n\tpublic appendPointToStroke(point: IInkPoint, id: string): IInkStroke {\n\t\tconst stylusOperation: IStylusOperation = {\n\t\t\tid,\n\t\t\tpoint,\n\t\t\ttype: \"stylus\",\n\t\t};\n\t\tthis.submitLocalMessage(stylusOperation, undefined);\n\t\treturn this.executeStylusOperation(stylusOperation);\n\t}\n\n\t/**\n\t * {@inheritDoc IInk.clear}\n\t */\n\tpublic clear(): void {\n\t\tconst clearOperation: IClearOperation = {\n\t\t\ttime: Date.now(),\n\t\t\ttype: \"clear\",\n\t\t};\n\t\tthis.submitLocalMessage(clearOperation, undefined);\n\t\tthis.executeClearOperation(clearOperation);\n\t}\n\n\t/**\n\t * {@inheritDoc IInk.getStrokes}\n\t */\n\tpublic getStrokes(): IInkStroke[] {\n\t\treturn this.inkData.getStrokes();\n\t}\n\n\t/**\n\t * {@inheritDoc IInk.getStroke}\n\t */\n\tpublic getStroke(key: string): IInkStroke {\n\t\treturn this.inkData.getStroke(key);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}\n\t */\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\tconst blobContent = JSON.stringify(this.inkData.getSerializable());\n\t\treturn createSingleBlobSummary(snapshotFileName, blobContent);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst content = await readAndParse<ISerializableInk>(storage, snapshotFileName);\n\t\tthis.inkData = new InkData(content);\n\t}\n\n\tprotected override processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, local, messagesContent } = messagesCollection;\n\t\tfor (const messageContent of messagesContent) {\n\t\t\tthis.processMessage(envelope, messageContent, local);\n\t\t}\n\t}\n\n\t/**\n\t * Process an ink operation message.\n\t *\n\t * @param messageEnvelope - The message envelope.\n\t * @param messageContent - The runtime message content containing the contents, i.e., payload and the\n\t * local op metadata. 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 * @param local - Whether or not the message was sent by the local client.\n\t */\n\tprivate processMessage(\n\t\tmessageEnvelope: ISequencedMessageEnvelope,\n\t\tmessageContent: IRuntimeMessagesContent,\n\t\tlocal: boolean,\n\t): void {\n\t\tif (messageEnvelope.type === MessageType.Operation && !local) {\n\t\t\tconst operation = messageContent.contents as IInkOperation;\n\t\t\tswitch (operation.type) {\n\t\t\t\tcase \"clear\": {\n\t\t\t\t\tthis.executeClearOperation(operation);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"createStroke\": {\n\t\t\t\t\tthis.executeCreateStrokeOperation(operation);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"stylus\": {\n\t\t\t\t\tthis.executeStylusOperation(operation);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}\n\t */\n\tprotected onDisconnect(): void {\n\t\treturn;\n\t}\n\n\t/**\n\t * Update the model for a clear operation.\n\t * @param operation - The operation object\n\t */\n\tprivate executeClearOperation(operation: IClearOperation): void {\n\t\tthis.inkData.clear();\n\t\tthis.emit(\"clear\", operation);\n\t}\n\n\t/**\n\t * Update the model for a create stroke operation.\n\t * @param operation - The operation object\n\t * @returns The stroke that was created\n\t */\n\tprivate executeCreateStrokeOperation(operation: ICreateStrokeOperation): IInkStroke {\n\t\tconst stroke: IInkStroke = {\n\t\t\tid: operation.id,\n\t\t\tpoints: [],\n\t\t\tpen: operation.pen,\n\t\t};\n\t\tthis.inkData.addStroke(stroke);\n\t\tthis.emit(\"createStroke\", operation);\n\t\treturn stroke;\n\t}\n\n\t/**\n\t * Update the model for a stylus operation. These represent updates to an existing stroke.\n\t * @param operation - The operation object\n\t * @returns The stroke that was updated\n\t */\n\tprivate executeStylusOperation(operation: IStylusOperation): IInkStroke {\n\t\t// Need to make sure the stroke is still there (hasn't been cleared) before appending the down/move/up.\n\t\tconst stroke = this.getStroke(operation.id);\n\t\tif (stroke !== undefined) {\n\t\t\tstroke.points.push(operation.point);\n\t\t\tthis.emit(\"stylus\", operation);\n\t\t}\n\t\treturn stroke;\n\t}\n\n\tprotected applyStashedOp(): void {\n\t\tthrow new Error(\"not implemented\");\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ink.js","sourceRoot":"","sources":["../src/ink.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,WAAW,EAAE,MAAM,6CAA6C,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAOrE,OAAO,EAEN,YAAY,EACZ,uBAAuB,GACvB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAY7C,OAAO,EAAyB,OAAO,EAAE,MAAM,eAAe,CAAC;AAE/D;;GAEG;AACH,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AACH,MAAM,OAAO,GAAI,SAAQ,YAAwB;IAChD;;;;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* Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { MessageType } from \"@fluidframework/driver-definitions/internal\";\nimport { readAndParse } from \"@fluidframework/driver-utils/internal\";\nimport type {\n\tISummaryTreeWithStats,\n\tIRuntimeMessageCollection,\n\tIRuntimeMessagesContent,\n\tISequencedMessageEnvelope,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\ttype IFluidSerializer,\n\tSharedObject,\n\tcreateSingleBlobSummary,\n} from \"@fluidframework/shared-object-base/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { InkFactory } from \"./inkFactory.js\";\nimport type {\n\tIClearOperation,\n\tICreateStrokeOperation,\n\tIInk,\n\tIInkEvents,\n\tIInkOperation,\n\tIInkPoint,\n\tIInkStroke,\n\tIPen,\n\tIStylusOperation,\n} from \"./interfaces.js\";\nimport { type ISerializableInk, InkData } from \"./snapshot.js\";\n\n/**\n * Filename where the snapshot is stored.\n */\nconst snapshotFileName = \"header\";\n\n/**\n * `Ink` is a shared object which holds a collection of ink strokes.\n *\n * @remarks\n * ### Creation and setup\n *\n * To create an `Ink` object, call the static `create` method:\n *\n * ```typescript\n * const ink = Ink.create(this.runtime, id);\n * ```\n *\n * You'll also need an `IPen` that will describe the style of your stroke:\n *\n * ```typescript\n * this.currentPen = {\n * color: { r: 0, g: 161 / 255, b: 241 / 255, a: 0 },\n * thickness: 7,\n * };\n * ```\n *\n * ### Usage\n *\n * Once the `Ink` object is created, you can add and update ink strokes using `createStroke` and\n * `appendPointToStroke`. Most likely you'll want to do this in response to incoming Pointer Events:\n *\n * ```typescript\n * private handlePointerDown(e: PointerEvent) {\n * const newStroke = ink.createStroke(this.currentPen);\n * this.currentStrokeId = newStroke.id;\n * handlePointerMotion(e);\n * }\n *\n * private handlePointerMotion(e: PointerEvent) {\n * const inkPoint = {\n * x: e.clientX,\n * y: e.clientY,\n * time: Date.now(),\n * pressure: e.pressure,\n * };\n * ink.appendPointToStroke(inkPoint, this.currentStrokeId);\n * }\n *\n * canvas.addEventListener(\"pointerdown\", this.handlePointerDown);\n * canvas.addEventListener(\"pointermove\", this.handlePointerMotion);\n * canvas.addEventListener(\"pointerup\", this.handlePointerMotion);\n * ```\n *\n * You can also clear all the ink with `clear`:\n *\n * ```typescript\n * ink.clear();\n * ```\n *\n * To observe and react to changes to the ink from both your own modifications as well as remote participants,\n * you can listen to the `\"createStroke\"`, `\"stylus\"` and `\"clear\"` events. Since you don't need to render anything\n * yet when a stroke is first created, registering for `\"createStroke\"` may not be necessary.\n *\n * ```typescript\n * ink.on(\"stylus\", this.renderStylusUpdate.bind(this));\n * ink.on(\"clear\", this.renderClear.bind(this));\n * ```\n * @sealed\n * @internal\n */\nexport class Ink extends SharedObject<IInkEvents> implements IInk {\n\t/**\n\t * Create a new Ink.\n\t * @param runtime - Data Store runtime the new Ink belongs to\n\t * @param id - Optional name of the Ink; will be assigned a unique ID if not provided\n\t * @returns Newly create Ink object (but not attached yet)\n\t */\n\tpublic static create(runtime: IFluidDataStoreRuntime, id?: string): Ink {\n\t\treturn runtime.createChannel(id, InkFactory.Type) as Ink;\n\t}\n\n\t/**\n\t * Get a factory for Ink to register with the data store.\n\t * @returns A factory that creates and loads Ink\n\t */\n\tpublic static getFactory(): InkFactory {\n\t\treturn new InkFactory();\n\t}\n\n\t/**\n\t * The current ink snapshot.\n\t */\n\tprivate inkData: InkData = new InkData();\n\n\t/**\n\t * Create a new Ink.\n\t * @param runtime - The runtime the Ink will be associated with\n\t * @param id - Unique ID for the Ink\n\t */\n\tconstructor(runtime: IFluidDataStoreRuntime, id: string, attributes: IChannelAttributes) {\n\t\tsuper(id, runtime, attributes, \"fluid_ink_\");\n\t}\n\n\tpublic createStroke(pen: IPen): IInkStroke {\n\t\tconst createStrokeOperation: ICreateStrokeOperation = {\n\t\t\tid: uuid(),\n\t\t\tpen,\n\t\t\ttime: Date.now(),\n\t\t\ttype: \"createStroke\",\n\t\t};\n\t\tthis.submitLocalMessage(createStrokeOperation, undefined);\n\t\treturn this.executeCreateStrokeOperation(createStrokeOperation);\n\t}\n\n\tpublic appendPointToStroke(point: IInkPoint, id: string): IInkStroke {\n\t\tconst stylusOperation: IStylusOperation = {\n\t\t\tid,\n\t\t\tpoint,\n\t\t\ttype: \"stylus\",\n\t\t};\n\t\tthis.submitLocalMessage(stylusOperation, undefined);\n\t\treturn this.executeStylusOperation(stylusOperation);\n\t}\n\n\tpublic clear(): void {\n\t\tconst clearOperation: IClearOperation = {\n\t\t\ttime: Date.now(),\n\t\t\ttype: \"clear\",\n\t\t};\n\t\tthis.submitLocalMessage(clearOperation, undefined);\n\t\tthis.executeClearOperation(clearOperation);\n\t}\n\n\tpublic getStrokes(): IInkStroke[] {\n\t\treturn this.inkData.getStrokes();\n\t}\n\n\tpublic getStroke(key: string): IInkStroke {\n\t\treturn this.inkData.getStroke(key);\n\t}\n\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\tconst blobContent = JSON.stringify(this.inkData.getSerializable());\n\t\treturn createSingleBlobSummary(snapshotFileName, blobContent);\n\t}\n\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst content = await readAndParse<ISerializableInk>(storage, snapshotFileName);\n\t\tthis.inkData = new InkData(content);\n\t}\n\n\tprotected override processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, local, messagesContent } = messagesCollection;\n\t\tfor (const messageContent of messagesContent) {\n\t\t\tthis.processMessage(envelope, messageContent, local);\n\t\t}\n\t}\n\n\t/**\n\t * Process an ink operation message.\n\t *\n\t * @param messageEnvelope - The message envelope.\n\t * @param messageContent - The runtime message content containing the contents, i.e., payload and the\n\t * local op metadata. 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 * @param local - Whether or not the message was sent by the local client.\n\t */\n\tprivate processMessage(\n\t\tmessageEnvelope: ISequencedMessageEnvelope,\n\t\tmessageContent: IRuntimeMessagesContent,\n\t\tlocal: boolean,\n\t): void {\n\t\tif (messageEnvelope.type === MessageType.Operation && !local) {\n\t\t\tconst operation = messageContent.contents as IInkOperation;\n\t\t\tswitch (operation.type) {\n\t\t\t\tcase \"clear\": {\n\t\t\t\t\tthis.executeClearOperation(operation);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"createStroke\": {\n\t\t\t\t\tthis.executeCreateStrokeOperation(operation);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"stylus\": {\n\t\t\t\t\tthis.executeStylusOperation(operation);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprotected onDisconnect(): void {\n\t\treturn;\n\t}\n\n\t/**\n\t * Update the model for a clear operation.\n\t * @param operation - The operation object\n\t */\n\tprivate executeClearOperation(operation: IClearOperation): void {\n\t\tthis.inkData.clear();\n\t\tthis.emit(\"clear\", operation);\n\t}\n\n\t/**\n\t * Update the model for a create stroke operation.\n\t * @param operation - The operation object\n\t * @returns The stroke that was created\n\t */\n\tprivate executeCreateStrokeOperation(operation: ICreateStrokeOperation): IInkStroke {\n\t\tconst stroke: IInkStroke = {\n\t\t\tid: operation.id,\n\t\t\tpoints: [],\n\t\t\tpen: operation.pen,\n\t\t};\n\t\tthis.inkData.addStroke(stroke);\n\t\tthis.emit(\"createStroke\", operation);\n\t\treturn stroke;\n\t}\n\n\t/**\n\t * Update the model for a stylus operation. These represent updates to an existing stroke.\n\t * @param operation - The operation object\n\t * @returns The stroke that was updated\n\t */\n\tprivate executeStylusOperation(operation: IStylusOperation): IInkStroke {\n\t\t// Need to make sure the stroke is still there (hasn't been cleared) before appending the down/move/up.\n\t\tconst stroke = this.getStroke(operation.id);\n\t\tif (stroke !== undefined) {\n\t\t\tstroke.points.push(operation.point);\n\t\t\tthis.emit(\"stylus\", operation);\n\t\t}\n\t\treturn stroke;\n\t}\n\n\tprotected applyStashedOp(): void {\n\t\tthrow new Error(\"not implemented\");\n\t}\n}\n"]}
|
package/lib/inkFactory.d.ts
CHANGED
|
@@ -18,21 +18,9 @@ export declare class InkFactory implements IChannelFactory {
|
|
|
18
18
|
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}
|
|
19
19
|
*/
|
|
20
20
|
static readonly Attributes: IChannelAttributes;
|
|
21
|
-
/**
|
|
22
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory."type"}
|
|
23
|
-
*/
|
|
24
21
|
get type(): string;
|
|
25
|
-
/**
|
|
26
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}
|
|
27
|
-
*/
|
|
28
22
|
get attributes(): IChannelAttributes;
|
|
29
|
-
/**
|
|
30
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
|
|
31
|
-
*/
|
|
32
23
|
load(runtime: IFluidDataStoreRuntime, id: string, services: IChannelServices, attributes: IChannelAttributes): Promise<ISharedObject>;
|
|
33
|
-
/**
|
|
34
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}
|
|
35
|
-
*/
|
|
36
24
|
create(runtime: IFluidDataStoreRuntime, id: string): ISharedObject;
|
|
37
25
|
}
|
|
38
26
|
//# sourceMappingURL=inkFactory.d.ts.map
|
package/lib/inkFactory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inkFactory.d.ts","sourceRoot":"","sources":["../src/inkFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,MAAM,gDAAgD,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAKjF;;;;GAIG;AACH,qBAAa,UAAW,YAAW,eAAe;IACjD;;OAEG;IAIH,OAAc,IAAI,SAA2C;IAE7D;;OAEG;IACH,gBAAuB,UAAU,EAAE,kBAAkB,CAInD;IAEF
|
|
1
|
+
{"version":3,"file":"inkFactory.d.ts","sourceRoot":"","sources":["../src/inkFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,MAAM,gDAAgD,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAKjF;;;;GAIG;AACH,qBAAa,UAAW,YAAW,eAAe;IACjD;;OAEG;IAIH,OAAc,IAAI,SAA2C;IAE7D;;OAEG;IACH,gBAAuB,UAAU,EAAE,kBAAkB,CAInD;IAEF,IAAW,IAAI,IAAI,MAAM,CAExB;IAED,IAAW,UAAU,IAAI,kBAAkB,CAE1C;IAEY,IAAI,CAChB,OAAO,EAAE,sBAAsB,EAC/B,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EAAE,kBAAkB,GAC5B,OAAO,CAAC,aAAa,CAAC;IAOlB,MAAM,CAAC,OAAO,EAAE,sBAAsB,EAAE,EAAE,EAAE,MAAM,GAAG,aAAa;CAMzE"}
|
package/lib/inkFactory.js
CHANGED
|
@@ -25,29 +25,17 @@ export class InkFactory {
|
|
|
25
25
|
snapshotFormatVersion: "0.2",
|
|
26
26
|
packageVersion: pkgVersion,
|
|
27
27
|
};
|
|
28
|
-
/**
|
|
29
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory."type"}
|
|
30
|
-
*/
|
|
31
28
|
get type() {
|
|
32
29
|
return InkFactory.Type;
|
|
33
30
|
}
|
|
34
|
-
/**
|
|
35
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}
|
|
36
|
-
*/
|
|
37
31
|
get attributes() {
|
|
38
32
|
return InkFactory.Attributes;
|
|
39
33
|
}
|
|
40
|
-
/**
|
|
41
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
|
|
42
|
-
*/
|
|
43
34
|
async load(runtime, id, services, attributes) {
|
|
44
35
|
const ink = new Ink(runtime, id, attributes);
|
|
45
36
|
await ink.load(services);
|
|
46
37
|
return ink;
|
|
47
38
|
}
|
|
48
|
-
/**
|
|
49
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}
|
|
50
|
-
*/
|
|
51
39
|
create(runtime, id) {
|
|
52
40
|
const ink = new Ink(runtime, id, InkFactory.Attributes);
|
|
53
41
|
ink.initializeLocal();
|
package/lib/inkFactory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inkFactory.js","sourceRoot":"","sources":["../src/inkFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD;;;;GAIG;AACH,MAAM,OAAO,UAAU;IACtB;;OAEG;IACH,uGAAuG;IACvG,qFAAqF;IACrF,8BAA8B;IACvB,MAAM,CAAC,IAAI,GAAG,uCAAuC,CAAC;IAE7D;;OAEG;IACI,MAAM,CAAU,UAAU,GAAuB;QACvD,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,qBAAqB,EAAE,KAAK;QAC5B,cAAc,EAAE,UAAU;KAC1B,CAAC;IAEF
|
|
1
|
+
{"version":3,"file":"inkFactory.js","sourceRoot":"","sources":["../src/inkFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD;;;;GAIG;AACH,MAAM,OAAO,UAAU;IACtB;;OAEG;IACH,uGAAuG;IACvG,qFAAqF;IACrF,8BAA8B;IACvB,MAAM,CAAC,IAAI,GAAG,uCAAuC,CAAC;IAE7D;;OAEG;IACI,MAAM,CAAU,UAAU,GAAuB;QACvD,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,qBAAqB,EAAE,KAAK;QAC5B,cAAc,EAAE,UAAU;KAC1B,CAAC;IAEF,IAAW,IAAI;QACd,OAAO,UAAU,CAAC,IAAI,CAAC;IACxB,CAAC;IAED,IAAW,UAAU;QACpB,OAAO,UAAU,CAAC,UAAU,CAAC;IAC9B,CAAC;IAEM,KAAK,CAAC,IAAI,CAChB,OAA+B,EAC/B,EAAU,EACV,QAA0B,EAC1B,UAA8B;QAE9B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,EAAE,EAAE,EAAE,UAAU,CAAC,CAAC;QAC7C,MAAM,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEzB,OAAO,GAAG,CAAC;IACZ,CAAC;IAEM,MAAM,CAAC,OAA+B,EAAE,EAAU;QACxD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,EAAE,EAAE,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;QACxD,GAAG,CAAC,eAAe,EAAE,CAAC;QAEtB,OAAO,GAAG,CAAC;IACZ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIChannelAttributes,\n\tIChannelFactory,\n\tIFluidDataStoreRuntime,\n\tIChannelServices,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type { ISharedObject } from \"@fluidframework/shared-object-base/internal\";\n\nimport { Ink } from \"./ink.js\";\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * Factory for Ink.\n * @sealed\n * @internal\n */\nexport class InkFactory implements IChannelFactory {\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.\"type\"}\n\t */\n\t// New type string, to be activated once the migration has been fully shipped dark and is safe to flip.\n\t// See LegacyTypeAwareRegistry in packages/runtime/datastore/src/dataStoreRuntime.ts.\n\t// public static Type = \"ink\";\n\tpublic static Type = \"https://graph.microsoft.com/types/ink\";\n\n\t/**\n\t * {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}\n\t */\n\tpublic static readonly Attributes: IChannelAttributes = {\n\t\ttype: InkFactory.Type,\n\t\tsnapshotFormatVersion: \"0.2\",\n\t\tpackageVersion: pkgVersion,\n\t};\n\n\tpublic get type(): string {\n\t\treturn InkFactory.Type;\n\t}\n\n\tpublic get attributes(): IChannelAttributes {\n\t\treturn InkFactory.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<ISharedObject> {\n\t\tconst ink = new Ink(runtime, id, attributes);\n\t\tawait ink.load(services);\n\n\t\treturn ink;\n\t}\n\n\tpublic create(runtime: IFluidDataStoreRuntime, id: string): ISharedObject {\n\t\tconst ink = new Ink(runtime, id, InkFactory.Attributes);\n\t\tink.initializeLocal();\n\n\t\treturn ink;\n\t}\n}\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
package/lib/packageVersion.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,yBAAyB,CAAC;AACjD,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluid-experimental/ink\";\nexport const pkgVersion = \"3.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,yBAAyB,CAAC;AACjD,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluid-experimental/ink\";\nexport const pkgVersion = \"3.6.0\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-experimental/ink",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "Ink DDS",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -41,23 +41,23 @@
|
|
|
41
41
|
"temp-directory": "nyc/.nyc_output"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@fluidframework/datastore-definitions": "~3.
|
|
45
|
-
"@fluidframework/driver-definitions": "~3.
|
|
46
|
-
"@fluidframework/driver-utils": "~3.
|
|
47
|
-
"@fluidframework/runtime-definitions": "~3.
|
|
48
|
-
"@fluidframework/shared-object-base": "~3.
|
|
44
|
+
"@fluidframework/datastore-definitions": "~3.6.0",
|
|
45
|
+
"@fluidframework/driver-definitions": "~3.6.0",
|
|
46
|
+
"@fluidframework/driver-utils": "~3.6.0",
|
|
47
|
+
"@fluidframework/runtime-definitions": "~3.6.0",
|
|
48
|
+
"@fluidframework/shared-object-base": "~3.6.0",
|
|
49
49
|
"uuid": "^11.1.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@arethetypeswrong/cli": "^0.18.5",
|
|
53
53
|
"@biomejs/biome": "~2.4.5",
|
|
54
|
-
"@fluid-internal/mocha-test-setup": "~3.
|
|
55
|
-
"@fluid-tools/build-cli": "^0.
|
|
54
|
+
"@fluid-internal/mocha-test-setup": "~3.6.0",
|
|
55
|
+
"@fluid-tools/build-cli": "^0.68.0",
|
|
56
56
|
"@fluidframework/build-common": "^2.0.3",
|
|
57
|
-
"@fluidframework/build-tools": "^0.
|
|
58
|
-
"@fluidframework/container-definitions": "~3.
|
|
57
|
+
"@fluidframework/build-tools": "^0.68.0",
|
|
58
|
+
"@fluidframework/container-definitions": "~3.6.0",
|
|
59
59
|
"@fluidframework/eslint-config-fluid": "^14.0.0",
|
|
60
|
-
"@fluidframework/test-runtime-utils": "~3.
|
|
60
|
+
"@fluidframework/test-runtime-utils": "~3.6.0",
|
|
61
61
|
"@microsoft/api-extractor": "7.58.1",
|
|
62
62
|
"@types/mocha": "^10.0.10",
|
|
63
63
|
"@types/node": "~22.19.17",
|
package/src/ink.ts
CHANGED
|
@@ -140,9 +140,6 @@ export class Ink extends SharedObject<IInkEvents> implements IInk {
|
|
|
140
140
|
super(id, runtime, attributes, "fluid_ink_");
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
/**
|
|
144
|
-
* {@inheritDoc IInk.createStroke}
|
|
145
|
-
*/
|
|
146
143
|
public createStroke(pen: IPen): IInkStroke {
|
|
147
144
|
const createStrokeOperation: ICreateStrokeOperation = {
|
|
148
145
|
id: uuid(),
|
|
@@ -154,9 +151,6 @@ export class Ink extends SharedObject<IInkEvents> implements IInk {
|
|
|
154
151
|
return this.executeCreateStrokeOperation(createStrokeOperation);
|
|
155
152
|
}
|
|
156
153
|
|
|
157
|
-
/**
|
|
158
|
-
* {@inheritDoc IInk.appendPointToStroke}
|
|
159
|
-
*/
|
|
160
154
|
public appendPointToStroke(point: IInkPoint, id: string): IInkStroke {
|
|
161
155
|
const stylusOperation: IStylusOperation = {
|
|
162
156
|
id,
|
|
@@ -167,9 +161,6 @@ export class Ink extends SharedObject<IInkEvents> implements IInk {
|
|
|
167
161
|
return this.executeStylusOperation(stylusOperation);
|
|
168
162
|
}
|
|
169
163
|
|
|
170
|
-
/**
|
|
171
|
-
* {@inheritDoc IInk.clear}
|
|
172
|
-
*/
|
|
173
164
|
public clear(): void {
|
|
174
165
|
const clearOperation: IClearOperation = {
|
|
175
166
|
time: Date.now(),
|
|
@@ -179,31 +170,19 @@ export class Ink extends SharedObject<IInkEvents> implements IInk {
|
|
|
179
170
|
this.executeClearOperation(clearOperation);
|
|
180
171
|
}
|
|
181
172
|
|
|
182
|
-
/**
|
|
183
|
-
* {@inheritDoc IInk.getStrokes}
|
|
184
|
-
*/
|
|
185
173
|
public getStrokes(): IInkStroke[] {
|
|
186
174
|
return this.inkData.getStrokes();
|
|
187
175
|
}
|
|
188
176
|
|
|
189
|
-
/**
|
|
190
|
-
* {@inheritDoc IInk.getStroke}
|
|
191
|
-
*/
|
|
192
177
|
public getStroke(key: string): IInkStroke {
|
|
193
178
|
return this.inkData.getStroke(key);
|
|
194
179
|
}
|
|
195
180
|
|
|
196
|
-
/**
|
|
197
|
-
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.summarizeCore}
|
|
198
|
-
*/
|
|
199
181
|
protected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {
|
|
200
182
|
const blobContent = JSON.stringify(this.inkData.getSerializable());
|
|
201
183
|
return createSingleBlobSummary(snapshotFileName, blobContent);
|
|
202
184
|
}
|
|
203
185
|
|
|
204
|
-
/**
|
|
205
|
-
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.loadCore}
|
|
206
|
-
*/
|
|
207
186
|
protected async loadCore(storage: IChannelStorageService): Promise<void> {
|
|
208
187
|
const content = await readAndParse<ISerializableInk>(storage, snapshotFileName);
|
|
209
188
|
this.inkData = new InkData(content);
|
|
@@ -252,9 +231,6 @@ export class Ink extends SharedObject<IInkEvents> implements IInk {
|
|
|
252
231
|
}
|
|
253
232
|
}
|
|
254
233
|
|
|
255
|
-
/**
|
|
256
|
-
* {@inheritDoc @fluidframework/shared-object-base#SharedObject.onDisconnect}
|
|
257
|
-
*/
|
|
258
234
|
protected onDisconnect(): void {
|
|
259
235
|
return;
|
|
260
236
|
}
|
package/src/inkFactory.ts
CHANGED
|
@@ -37,23 +37,14 @@ export class InkFactory implements IChannelFactory {
|
|
|
37
37
|
packageVersion: pkgVersion,
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
/**
|
|
41
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory."type"}
|
|
42
|
-
*/
|
|
43
40
|
public get type(): string {
|
|
44
41
|
return InkFactory.Type;
|
|
45
42
|
}
|
|
46
43
|
|
|
47
|
-
/**
|
|
48
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.attributes}
|
|
49
|
-
*/
|
|
50
44
|
public get attributes(): IChannelAttributes {
|
|
51
45
|
return InkFactory.Attributes;
|
|
52
46
|
}
|
|
53
47
|
|
|
54
|
-
/**
|
|
55
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.load}
|
|
56
|
-
*/
|
|
57
48
|
public async load(
|
|
58
49
|
runtime: IFluidDataStoreRuntime,
|
|
59
50
|
id: string,
|
|
@@ -66,9 +57,6 @@ export class InkFactory implements IChannelFactory {
|
|
|
66
57
|
return ink;
|
|
67
58
|
}
|
|
68
59
|
|
|
69
|
-
/**
|
|
70
|
-
* {@inheritDoc @fluidframework/datastore-definitions#IChannelFactory.create}
|
|
71
|
-
*/
|
|
72
60
|
public create(runtime: IFluidDataStoreRuntime, id: string): ISharedObject {
|
|
73
61
|
const ink = new Ink(runtime, id, InkFactory.Attributes);
|
|
74
62
|
ink.initializeLocal();
|
package/src/packageVersion.ts
CHANGED