@fluidframework/shared-object-base 2.31.1 → 2.32.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 +4 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/serializer.d.ts +29 -1
- package/dist/serializer.d.ts.map +1 -1
- package/dist/serializer.js +32 -16
- package/dist/serializer.js.map +1 -1
- package/dist/sharedObject.d.ts.map +1 -1
- package/dist/sharedObject.js +4 -1
- package/dist/sharedObject.js.map +1 -1
- package/dist/summarySerializer.d.ts +1 -1
- package/dist/summarySerializer.d.ts.map +1 -1
- package/dist/summarySerializer.js +2 -2
- package/dist/summarySerializer.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/lib/serializer.d.ts +29 -1
- package/lib/serializer.d.ts.map +1 -1
- package/lib/serializer.js +32 -16
- package/lib/serializer.js.map +1 -1
- package/lib/sharedObject.d.ts.map +1 -1
- package/lib/sharedObject.js +4 -1
- package/lib/sharedObject.js.map +1 -1
- package/lib/summarySerializer.d.ts +1 -1
- package/lib/summarySerializer.d.ts.map +1 -1
- package/lib/summarySerializer.js +2 -2
- package/lib/summarySerializer.js.map +1 -1
- package/package.json +16 -17
- package/src/packageVersion.ts +1 -1
- package/src/serializer.ts +33 -16
- package/src/sharedObject.ts +5 -4
- package/src/summarySerializer.ts +2 -2
- package/dist/remoteObjectHandle.d.ts +0 -30
- package/dist/remoteObjectHandle.d.ts.map +0 -1
- package/dist/remoteObjectHandle.js +0 -56
- package/dist/remoteObjectHandle.js.map +0 -1
- package/lib/remoteObjectHandle.d.ts +0 -30
- package/lib/remoteObjectHandle.d.ts.map +0 -1
- package/lib/remoteObjectHandle.js +0 -52
- package/lib/remoteObjectHandle.js.map +0 -1
- package/src/remoteObjectHandle.ts +0 -67
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/shared-object-base",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.32.0",
|
|
4
4
|
"description": "Fluid base class for shared distributed data structures",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -69,30 +69,29 @@
|
|
|
69
69
|
"temp-directory": "nyc/.nyc_output"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@fluid-internal/client-utils": "~2.
|
|
73
|
-
"@fluidframework/container-definitions": "~2.
|
|
74
|
-
"@fluidframework/
|
|
75
|
-
"@fluidframework/core-
|
|
76
|
-
"@fluidframework/
|
|
77
|
-
"@fluidframework/datastore": "~2.
|
|
78
|
-
"@fluidframework/
|
|
79
|
-
"@fluidframework/
|
|
80
|
-
"@fluidframework/runtime-
|
|
81
|
-
"@fluidframework/
|
|
82
|
-
"@fluidframework/telemetry-utils": "~2.31.1",
|
|
72
|
+
"@fluid-internal/client-utils": "~2.32.0",
|
|
73
|
+
"@fluidframework/container-definitions": "~2.32.0",
|
|
74
|
+
"@fluidframework/core-interfaces": "~2.32.0",
|
|
75
|
+
"@fluidframework/core-utils": "~2.32.0",
|
|
76
|
+
"@fluidframework/datastore": "~2.32.0",
|
|
77
|
+
"@fluidframework/datastore-definitions": "~2.32.0",
|
|
78
|
+
"@fluidframework/driver-definitions": "~2.32.0",
|
|
79
|
+
"@fluidframework/runtime-definitions": "~2.32.0",
|
|
80
|
+
"@fluidframework/runtime-utils": "~2.32.0",
|
|
81
|
+
"@fluidframework/telemetry-utils": "~2.32.0",
|
|
83
82
|
"uuid": "^9.0.0"
|
|
84
83
|
},
|
|
85
84
|
"devDependencies": {
|
|
86
85
|
"@arethetypeswrong/cli": "^0.17.1",
|
|
87
86
|
"@biomejs/biome": "~1.9.3",
|
|
88
|
-
"@fluid-internal/mocha-test-setup": "~2.
|
|
89
|
-
"@fluid-private/test-pairwise-generator": "~2.
|
|
90
|
-
"@fluid-tools/build-cli": "^0.
|
|
87
|
+
"@fluid-internal/mocha-test-setup": "~2.32.0",
|
|
88
|
+
"@fluid-private/test-pairwise-generator": "~2.32.0",
|
|
89
|
+
"@fluid-tools/build-cli": "^0.55.0",
|
|
91
90
|
"@fluidframework/build-common": "^2.0.3",
|
|
92
|
-
"@fluidframework/build-tools": "^0.
|
|
91
|
+
"@fluidframework/build-tools": "^0.55.0",
|
|
93
92
|
"@fluidframework/eslint-config-fluid": "^5.7.3",
|
|
94
93
|
"@fluidframework/shared-object-base-previous": "npm:@fluidframework/shared-object-base@2.31.0",
|
|
95
|
-
"@fluidframework/test-runtime-utils": "~2.
|
|
94
|
+
"@fluidframework/test-runtime-utils": "~2.32.0",
|
|
96
95
|
"@microsoft/api-extractor": "7.50.1",
|
|
97
96
|
"@types/benchmark": "^2.1.0",
|
|
98
97
|
"@types/mocha": "^10.0.10",
|
package/src/packageVersion.ts
CHANGED
package/src/serializer.ts
CHANGED
|
@@ -10,15 +10,15 @@ import {
|
|
|
10
10
|
} from "@fluidframework/core-interfaces/internal";
|
|
11
11
|
import { assert, shallowCloneObject } from "@fluidframework/core-utils/internal";
|
|
12
12
|
import {
|
|
13
|
+
encodeHandleForSerialization,
|
|
13
14
|
generateHandleContextPath,
|
|
14
15
|
isSerializedHandle,
|
|
15
16
|
isFluidHandle,
|
|
16
17
|
toFluidHandleInternal,
|
|
17
18
|
type ISerializedHandle,
|
|
19
|
+
RemoteFluidObjectHandle,
|
|
18
20
|
} from "@fluidframework/runtime-utils/internal";
|
|
19
21
|
|
|
20
|
-
import { RemoteFluidObjectHandle } from "./remoteObjectHandle.js";
|
|
21
|
-
|
|
22
22
|
/**
|
|
23
23
|
* @legacy
|
|
24
24
|
* @alpha
|
|
@@ -110,29 +110,40 @@ export class FluidSerializer implements IFluidSerializer {
|
|
|
110
110
|
: input;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Serializes the input object into a JSON string.
|
|
115
|
+
* Any IFluidHandles in the object will be replaced with their serialized form before stringify,
|
|
116
|
+
* being bound to the given bind context in the process.
|
|
117
|
+
*/
|
|
113
118
|
public stringify(input: unknown, bind: IFluidHandle): string {
|
|
114
119
|
const bindInternal = toFluidHandleInternal(bind);
|
|
115
120
|
return JSON.stringify(input, (key, value) => this.encodeValue(value, bindInternal));
|
|
116
121
|
}
|
|
117
122
|
|
|
118
|
-
|
|
123
|
+
/**
|
|
124
|
+
* Parses the serialized data - context must match the context with which the JSON was stringified
|
|
125
|
+
*/
|
|
119
126
|
public parse(input: string): unknown {
|
|
120
127
|
return JSON.parse(input, (key, value) => this.decodeValue(value));
|
|
121
128
|
}
|
|
122
129
|
|
|
123
|
-
|
|
124
|
-
|
|
130
|
+
/**
|
|
131
|
+
* If the given 'value' is an IFluidHandle, returns the encoded IFluidHandle.
|
|
132
|
+
* Otherwise returns the original 'value'. Used by 'encode()' and 'stringify()'.
|
|
133
|
+
*/
|
|
125
134
|
private readonly encodeValue = (value: unknown, bind?: IFluidHandleInternal): unknown => {
|
|
126
135
|
// If 'value' is an IFluidHandle return its encoded form.
|
|
127
136
|
if (isFluidHandle(value)) {
|
|
128
137
|
assert(bind !== undefined, 0xa93 /* Cannot encode a handle without a bind context */);
|
|
129
|
-
return this.
|
|
138
|
+
return this.bindAndEncodeHandle(toFluidHandleInternal(value), bind);
|
|
130
139
|
}
|
|
131
140
|
return value;
|
|
132
141
|
};
|
|
133
142
|
|
|
134
|
-
|
|
135
|
-
|
|
143
|
+
/**
|
|
144
|
+
* If the given 'value' is an encoded IFluidHandle, returns the decoded IFluidHandle.
|
|
145
|
+
* Otherwise returns the original 'value'. Used by 'decode()' and 'parse()'.
|
|
146
|
+
*/
|
|
136
147
|
private readonly decodeValue = (value: unknown): unknown => {
|
|
137
148
|
// If 'value' is a serialized IFluidHandle return the deserialized result.
|
|
138
149
|
if (isSerializedHandle(value)) {
|
|
@@ -148,9 +159,11 @@ export class FluidSerializer implements IFluidSerializer {
|
|
|
148
159
|
}
|
|
149
160
|
};
|
|
150
161
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
162
|
+
/**
|
|
163
|
+
* Invoked for non-null objects to recursively replace references to IFluidHandles.
|
|
164
|
+
* Clones as-needed to avoid mutating the `input` object. If no IFluidHandles are present,
|
|
165
|
+
* returns the original `input`.
|
|
166
|
+
*/
|
|
154
167
|
private recursivelyReplace<TContext = unknown>(
|
|
155
168
|
input: object,
|
|
156
169
|
replacer: (input: unknown, context?: TContext) => unknown,
|
|
@@ -195,14 +208,18 @@ export class FluidSerializer implements IFluidSerializer {
|
|
|
195
208
|
return clone ?? input;
|
|
196
209
|
}
|
|
197
210
|
|
|
198
|
-
|
|
211
|
+
/**
|
|
212
|
+
* Encodes the given IFluidHandle into a JSON-serializable form,
|
|
213
|
+
* also binding it to another node to ensure it attaches at the right time.
|
|
214
|
+
* @param handle - The IFluidHandle to serialize.
|
|
215
|
+
* @param bind - The binding context for the handle (the handle will become attached whenever this context is attached).
|
|
216
|
+
* @returns The serialized handle.
|
|
217
|
+
*/
|
|
218
|
+
protected bindAndEncodeHandle(
|
|
199
219
|
handle: IFluidHandleInternal,
|
|
200
220
|
bind: IFluidHandleInternal,
|
|
201
221
|
): ISerializedHandle {
|
|
202
222
|
bind.bind(handle);
|
|
203
|
-
return
|
|
204
|
-
type: "__fluid_handle__",
|
|
205
|
-
url: handle.absolutePath,
|
|
206
|
-
};
|
|
223
|
+
return encodeHandleForSerialization(handle);
|
|
207
224
|
}
|
|
208
225
|
}
|
package/src/sharedObject.ts
CHANGED
|
@@ -458,11 +458,12 @@ export abstract class SharedObjectCore<
|
|
|
458
458
|
protected submitLocalMessage(content: unknown, localOpMetadata: unknown = undefined): void {
|
|
459
459
|
this.verifyNotClosed();
|
|
460
460
|
if (this.isAttached()) {
|
|
461
|
+
// NOTE: We may also be encoding in the ContainerRuntime layer.
|
|
462
|
+
// Once the layer-compat window passes we can stop encoding here and only bind
|
|
463
|
+
const contentToSubmit = makeHandlesSerializable(content, this.serializer, this.handle);
|
|
464
|
+
|
|
461
465
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
462
|
-
this.services!.deltaConnection.submit(
|
|
463
|
-
makeHandlesSerializable(content, this.serializer, this.handle),
|
|
464
|
-
localOpMetadata,
|
|
465
|
-
);
|
|
466
|
+
this.services!.deltaConnection.submit(contentToSubmit, localOpMetadata);
|
|
466
467
|
}
|
|
467
468
|
}
|
|
468
469
|
|
package/src/summarySerializer.ts
CHANGED
|
@@ -18,11 +18,11 @@ export class SummarySerializer extends FluidSerializer {
|
|
|
18
18
|
return [...this.serializedRoutes];
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
protected
|
|
21
|
+
protected bindAndEncodeHandle(
|
|
22
22
|
handle: IFluidHandleInternal,
|
|
23
23
|
bind: IFluidHandleInternal,
|
|
24
24
|
): ISerializedHandle {
|
|
25
25
|
this.serializedRoutes.add(handle.absolutePath);
|
|
26
|
-
return super.
|
|
26
|
+
return super.bindAndEncodeHandle(handle, bind);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import { FluidObject } from "@fluidframework/core-interfaces";
|
|
6
|
-
import { IFluidHandleContext, type IFluidHandleInternal } from "@fluidframework/core-interfaces/internal";
|
|
7
|
-
import { FluidHandleBase } from "@fluidframework/runtime-utils/internal";
|
|
8
|
-
/**
|
|
9
|
-
* This handle is used to dynamically load a Fluid object on a remote client and is created on parsing a serialized
|
|
10
|
-
* FluidObjectHandle.
|
|
11
|
-
* This class is used to generate an IFluidHandle when de-serializing any all handles (including handles to DDSes,
|
|
12
|
-
* custom objects) that are stored in SharedObjects. The Data Store or SharedObject corresponding to the
|
|
13
|
-
* IFluidHandle can be retrieved by calling `get` on it.
|
|
14
|
-
*/
|
|
15
|
-
export declare class RemoteFluidObjectHandle extends FluidHandleBase<FluidObject> {
|
|
16
|
-
readonly absolutePath: string;
|
|
17
|
-
readonly routeContext: IFluidHandleContext;
|
|
18
|
-
readonly isAttached = true;
|
|
19
|
-
private objectP;
|
|
20
|
-
/**
|
|
21
|
-
* Creates a new RemoteFluidObjectHandle when parsing an IFluidHandle.
|
|
22
|
-
* @param absolutePath - The absolute path to the handle from the container runtime.
|
|
23
|
-
* @param routeContext - The root IFluidHandleContext that has a route to this handle.
|
|
24
|
-
*/
|
|
25
|
-
constructor(absolutePath: string, routeContext: IFluidHandleContext);
|
|
26
|
-
get(): Promise<FluidObject>;
|
|
27
|
-
attachGraph(): void;
|
|
28
|
-
bind(handle: IFluidHandleInternal): void;
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=remoteObjectHandle.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remoteObjectHandle.d.ts","sourceRoot":"","sources":["../src/remoteObjectHandle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,WAAW,EAAY,MAAM,iCAAiC,CAAC;AACxE,OAAO,EACN,mBAAmB,EACnB,KAAK,oBAAoB,EACzB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,eAAe,EAAuB,MAAM,wCAAwC,CAAC;AAE9F;;;;;;GAMG;AACH,qBAAa,uBAAwB,SAAQ,eAAe,CAAC,WAAW,CAAC;aAUvD,YAAY,EAAE,MAAM;aACpB,YAAY,EAAE,mBAAmB;IAVlD,SAAgB,UAAU,QAAQ;IAClC,OAAO,CAAC,OAAO,CAAmC;IAElD;;;;OAIG;gBAEc,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,mBAAmB;IASrC,GAAG,IAAI,OAAO,CAAC,WAAW,CAAC;IAkBjC,WAAW,IAAI,IAAI;IAInB,IAAI,CAAC,MAAM,EAAE,oBAAoB,GAAG,IAAI;CAG/C"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.RemoteFluidObjectHandle = void 0;
|
|
8
|
-
const internal_1 = require("@fluidframework/container-runtime/internal");
|
|
9
|
-
const internal_2 = require("@fluidframework/core-utils/internal");
|
|
10
|
-
const internal_3 = require("@fluidframework/runtime-utils/internal");
|
|
11
|
-
/**
|
|
12
|
-
* This handle is used to dynamically load a Fluid object on a remote client and is created on parsing a serialized
|
|
13
|
-
* FluidObjectHandle.
|
|
14
|
-
* This class is used to generate an IFluidHandle when de-serializing any all handles (including handles to DDSes,
|
|
15
|
-
* custom objects) that are stored in SharedObjects. The Data Store or SharedObject corresponding to the
|
|
16
|
-
* IFluidHandle can be retrieved by calling `get` on it.
|
|
17
|
-
*/
|
|
18
|
-
class RemoteFluidObjectHandle extends internal_3.FluidHandleBase {
|
|
19
|
-
/**
|
|
20
|
-
* Creates a new RemoteFluidObjectHandle when parsing an IFluidHandle.
|
|
21
|
-
* @param absolutePath - The absolute path to the handle from the container runtime.
|
|
22
|
-
* @param routeContext - The root IFluidHandleContext that has a route to this handle.
|
|
23
|
-
*/
|
|
24
|
-
constructor(absolutePath, routeContext) {
|
|
25
|
-
super();
|
|
26
|
-
this.absolutePath = absolutePath;
|
|
27
|
-
this.routeContext = routeContext;
|
|
28
|
-
this.isAttached = true;
|
|
29
|
-
(0, internal_2.assert)(absolutePath.startsWith("/"), 0x19d /* "Handles should always have absolute paths" */);
|
|
30
|
-
}
|
|
31
|
-
async get() {
|
|
32
|
-
if (this.objectP === undefined) {
|
|
33
|
-
// Add `viaHandle` header to distinguish from requests from non-handle paths.
|
|
34
|
-
const request = {
|
|
35
|
-
url: this.absolutePath,
|
|
36
|
-
headers: { [internal_1.RuntimeHeaders.viaHandle]: true },
|
|
37
|
-
};
|
|
38
|
-
this.objectP = this.routeContext.resolveHandle(request).then((response) => {
|
|
39
|
-
if (response.mimeType === "fluid/object") {
|
|
40
|
-
const fluidObject = response.value;
|
|
41
|
-
return fluidObject;
|
|
42
|
-
}
|
|
43
|
-
throw (0, internal_3.responseToException)(response, request);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
return this.objectP;
|
|
47
|
-
}
|
|
48
|
-
attachGraph() {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
bind(handle) {
|
|
52
|
-
handle.attachGraph();
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
exports.RemoteFluidObjectHandle = RemoteFluidObjectHandle;
|
|
56
|
-
//# sourceMappingURL=remoteObjectHandle.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remoteObjectHandle.js","sourceRoot":"","sources":["../src/remoteObjectHandle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yEAA4E;AAM5E,kEAA6D;AAC7D,qEAA8F;AAE9F;;;;;;GAMG;AACH,MAAa,uBAAwB,SAAQ,0BAA4B;IAIxE;;;;OAIG;IACH,YACiB,YAAoB,EACpB,YAAiC;QAEjD,KAAK,EAAE,CAAC;QAHQ,iBAAY,GAAZ,YAAY,CAAQ;QACpB,iBAAY,GAAZ,YAAY,CAAqB;QAVlC,eAAU,GAAG,IAAI,CAAC;QAajC,IAAA,iBAAM,EACL,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,EAC5B,KAAK,CAAC,iDAAiD,CACvD,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,GAAG;QACf,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YAChC,6EAA6E;YAC7E,MAAM,OAAO,GAAa;gBACzB,GAAG,EAAE,IAAI,CAAC,YAAY;gBACtB,OAAO,EAAE,EAAE,CAAC,yBAAc,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE;aAC7C,CAAC;YACF,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,IAAI,CAAc,CAAC,QAAQ,EAAE,EAAE;gBACtF,IAAI,QAAQ,CAAC,QAAQ,KAAK,cAAc,EAAE,CAAC;oBAC1C,MAAM,WAAW,GAAgB,QAAQ,CAAC,KAAoB,CAAC;oBAC/D,OAAO,WAAW,CAAC;gBACpB,CAAC;gBACD,MAAM,IAAA,8BAAmB,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YAC9C,CAAC,CAAC,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAEM,WAAW;QACjB,OAAO;IACR,CAAC;IAEM,IAAI,CAAC,MAA4B;QACvC,MAAM,CAAC,WAAW,EAAE,CAAC;IACtB,CAAC;CACD;AA7CD,0DA6CC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { RuntimeHeaders } from \"@fluidframework/container-runtime/internal\";\nimport { FluidObject, IRequest } from \"@fluidframework/core-interfaces\";\nimport {\n\tIFluidHandleContext,\n\ttype IFluidHandleInternal,\n} from \"@fluidframework/core-interfaces/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { FluidHandleBase, responseToException } from \"@fluidframework/runtime-utils/internal\";\n\n/**\n * This handle is used to dynamically load a Fluid object on a remote client and is created on parsing a serialized\n * FluidObjectHandle.\n * This class is used to generate an IFluidHandle when de-serializing any all handles (including handles to DDSes,\n * custom objects) that are stored in SharedObjects. The Data Store or SharedObject corresponding to the\n * IFluidHandle can be retrieved by calling `get` on it.\n */\nexport class RemoteFluidObjectHandle extends FluidHandleBase<FluidObject> {\n\tpublic readonly isAttached = true;\n\tprivate objectP: Promise<FluidObject> | undefined;\n\n\t/**\n\t * Creates a new RemoteFluidObjectHandle when parsing an IFluidHandle.\n\t * @param absolutePath - The absolute path to the handle from the container runtime.\n\t * @param routeContext - The root IFluidHandleContext that has a route to this handle.\n\t */\n\tconstructor(\n\t\tpublic readonly absolutePath: string,\n\t\tpublic readonly routeContext: IFluidHandleContext,\n\t) {\n\t\tsuper();\n\t\tassert(\n\t\t\tabsolutePath.startsWith(\"/\"),\n\t\t\t0x19d /* \"Handles should always have absolute paths\" */,\n\t\t);\n\t}\n\n\tpublic async get(): Promise<FluidObject> {\n\t\tif (this.objectP === undefined) {\n\t\t\t// Add `viaHandle` header to distinguish from requests from non-handle paths.\n\t\t\tconst request: IRequest = {\n\t\t\t\turl: this.absolutePath,\n\t\t\t\theaders: { [RuntimeHeaders.viaHandle]: true },\n\t\t\t};\n\t\t\tthis.objectP = this.routeContext.resolveHandle(request).then<FluidObject>((response) => {\n\t\t\t\tif (response.mimeType === \"fluid/object\") {\n\t\t\t\t\tconst fluidObject: FluidObject = response.value as FluidObject;\n\t\t\t\t\treturn fluidObject;\n\t\t\t\t}\n\t\t\t\tthrow responseToException(response, request);\n\t\t\t});\n\t\t}\n\t\treturn this.objectP;\n\t}\n\n\tpublic attachGraph(): void {\n\t\treturn;\n\t}\n\n\tpublic bind(handle: IFluidHandleInternal): void {\n\t\thandle.attachGraph();\n\t}\n}\n"]}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import { FluidObject } from "@fluidframework/core-interfaces";
|
|
6
|
-
import { IFluidHandleContext, type IFluidHandleInternal } from "@fluidframework/core-interfaces/internal";
|
|
7
|
-
import { FluidHandleBase } from "@fluidframework/runtime-utils/internal";
|
|
8
|
-
/**
|
|
9
|
-
* This handle is used to dynamically load a Fluid object on a remote client and is created on parsing a serialized
|
|
10
|
-
* FluidObjectHandle.
|
|
11
|
-
* This class is used to generate an IFluidHandle when de-serializing any all handles (including handles to DDSes,
|
|
12
|
-
* custom objects) that are stored in SharedObjects. The Data Store or SharedObject corresponding to the
|
|
13
|
-
* IFluidHandle can be retrieved by calling `get` on it.
|
|
14
|
-
*/
|
|
15
|
-
export declare class RemoteFluidObjectHandle extends FluidHandleBase<FluidObject> {
|
|
16
|
-
readonly absolutePath: string;
|
|
17
|
-
readonly routeContext: IFluidHandleContext;
|
|
18
|
-
readonly isAttached = true;
|
|
19
|
-
private objectP;
|
|
20
|
-
/**
|
|
21
|
-
* Creates a new RemoteFluidObjectHandle when parsing an IFluidHandle.
|
|
22
|
-
* @param absolutePath - The absolute path to the handle from the container runtime.
|
|
23
|
-
* @param routeContext - The root IFluidHandleContext that has a route to this handle.
|
|
24
|
-
*/
|
|
25
|
-
constructor(absolutePath: string, routeContext: IFluidHandleContext);
|
|
26
|
-
get(): Promise<FluidObject>;
|
|
27
|
-
attachGraph(): void;
|
|
28
|
-
bind(handle: IFluidHandleInternal): void;
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=remoteObjectHandle.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remoteObjectHandle.d.ts","sourceRoot":"","sources":["../src/remoteObjectHandle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,WAAW,EAAY,MAAM,iCAAiC,CAAC;AACxE,OAAO,EACN,mBAAmB,EACnB,KAAK,oBAAoB,EACzB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,eAAe,EAAuB,MAAM,wCAAwC,CAAC;AAE9F;;;;;;GAMG;AACH,qBAAa,uBAAwB,SAAQ,eAAe,CAAC,WAAW,CAAC;aAUvD,YAAY,EAAE,MAAM;aACpB,YAAY,EAAE,mBAAmB;IAVlD,SAAgB,UAAU,QAAQ;IAClC,OAAO,CAAC,OAAO,CAAmC;IAElD;;;;OAIG;gBAEc,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,mBAAmB;IASrC,GAAG,IAAI,OAAO,CAAC,WAAW,CAAC;IAkBjC,WAAW,IAAI,IAAI;IAInB,IAAI,CAAC,MAAM,EAAE,oBAAoB,GAAG,IAAI;CAG/C"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import { RuntimeHeaders } from "@fluidframework/container-runtime/internal";
|
|
6
|
-
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
|
-
import { FluidHandleBase, responseToException } from "@fluidframework/runtime-utils/internal";
|
|
8
|
-
/**
|
|
9
|
-
* This handle is used to dynamically load a Fluid object on a remote client and is created on parsing a serialized
|
|
10
|
-
* FluidObjectHandle.
|
|
11
|
-
* This class is used to generate an IFluidHandle when de-serializing any all handles (including handles to DDSes,
|
|
12
|
-
* custom objects) that are stored in SharedObjects. The Data Store or SharedObject corresponding to the
|
|
13
|
-
* IFluidHandle can be retrieved by calling `get` on it.
|
|
14
|
-
*/
|
|
15
|
-
export class RemoteFluidObjectHandle extends FluidHandleBase {
|
|
16
|
-
/**
|
|
17
|
-
* Creates a new RemoteFluidObjectHandle when parsing an IFluidHandle.
|
|
18
|
-
* @param absolutePath - The absolute path to the handle from the container runtime.
|
|
19
|
-
* @param routeContext - The root IFluidHandleContext that has a route to this handle.
|
|
20
|
-
*/
|
|
21
|
-
constructor(absolutePath, routeContext) {
|
|
22
|
-
super();
|
|
23
|
-
this.absolutePath = absolutePath;
|
|
24
|
-
this.routeContext = routeContext;
|
|
25
|
-
this.isAttached = true;
|
|
26
|
-
assert(absolutePath.startsWith("/"), 0x19d /* "Handles should always have absolute paths" */);
|
|
27
|
-
}
|
|
28
|
-
async get() {
|
|
29
|
-
if (this.objectP === undefined) {
|
|
30
|
-
// Add `viaHandle` header to distinguish from requests from non-handle paths.
|
|
31
|
-
const request = {
|
|
32
|
-
url: this.absolutePath,
|
|
33
|
-
headers: { [RuntimeHeaders.viaHandle]: true },
|
|
34
|
-
};
|
|
35
|
-
this.objectP = this.routeContext.resolveHandle(request).then((response) => {
|
|
36
|
-
if (response.mimeType === "fluid/object") {
|
|
37
|
-
const fluidObject = response.value;
|
|
38
|
-
return fluidObject;
|
|
39
|
-
}
|
|
40
|
-
throw responseToException(response, request);
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
return this.objectP;
|
|
44
|
-
}
|
|
45
|
-
attachGraph() {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
bind(handle) {
|
|
49
|
-
handle.attachGraph();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=remoteObjectHandle.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remoteObjectHandle.js","sourceRoot":"","sources":["../src/remoteObjectHandle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAM5E,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAE9F;;;;;;GAMG;AACH,MAAM,OAAO,uBAAwB,SAAQ,eAA4B;IAIxE;;;;OAIG;IACH,YACiB,YAAoB,EACpB,YAAiC;QAEjD,KAAK,EAAE,CAAC;QAHQ,iBAAY,GAAZ,YAAY,CAAQ;QACpB,iBAAY,GAAZ,YAAY,CAAqB;QAVlC,eAAU,GAAG,IAAI,CAAC;QAajC,MAAM,CACL,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,EAC5B,KAAK,CAAC,iDAAiD,CACvD,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,GAAG;QACf,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YAChC,6EAA6E;YAC7E,MAAM,OAAO,GAAa;gBACzB,GAAG,EAAE,IAAI,CAAC,YAAY;gBACtB,OAAO,EAAE,EAAE,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE;aAC7C,CAAC;YACF,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,IAAI,CAAc,CAAC,QAAQ,EAAE,EAAE;gBACtF,IAAI,QAAQ,CAAC,QAAQ,KAAK,cAAc,EAAE,CAAC;oBAC1C,MAAM,WAAW,GAAgB,QAAQ,CAAC,KAAoB,CAAC;oBAC/D,OAAO,WAAW,CAAC;gBACpB,CAAC;gBACD,MAAM,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YAC9C,CAAC,CAAC,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAEM,WAAW;QACjB,OAAO;IACR,CAAC;IAEM,IAAI,CAAC,MAA4B;QACvC,MAAM,CAAC,WAAW,EAAE,CAAC;IACtB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { RuntimeHeaders } from \"@fluidframework/container-runtime/internal\";\nimport { FluidObject, IRequest } from \"@fluidframework/core-interfaces\";\nimport {\n\tIFluidHandleContext,\n\ttype IFluidHandleInternal,\n} from \"@fluidframework/core-interfaces/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { FluidHandleBase, responseToException } from \"@fluidframework/runtime-utils/internal\";\n\n/**\n * This handle is used to dynamically load a Fluid object on a remote client and is created on parsing a serialized\n * FluidObjectHandle.\n * This class is used to generate an IFluidHandle when de-serializing any all handles (including handles to DDSes,\n * custom objects) that are stored in SharedObjects. The Data Store or SharedObject corresponding to the\n * IFluidHandle can be retrieved by calling `get` on it.\n */\nexport class RemoteFluidObjectHandle extends FluidHandleBase<FluidObject> {\n\tpublic readonly isAttached = true;\n\tprivate objectP: Promise<FluidObject> | undefined;\n\n\t/**\n\t * Creates a new RemoteFluidObjectHandle when parsing an IFluidHandle.\n\t * @param absolutePath - The absolute path to the handle from the container runtime.\n\t * @param routeContext - The root IFluidHandleContext that has a route to this handle.\n\t */\n\tconstructor(\n\t\tpublic readonly absolutePath: string,\n\t\tpublic readonly routeContext: IFluidHandleContext,\n\t) {\n\t\tsuper();\n\t\tassert(\n\t\t\tabsolutePath.startsWith(\"/\"),\n\t\t\t0x19d /* \"Handles should always have absolute paths\" */,\n\t\t);\n\t}\n\n\tpublic async get(): Promise<FluidObject> {\n\t\tif (this.objectP === undefined) {\n\t\t\t// Add `viaHandle` header to distinguish from requests from non-handle paths.\n\t\t\tconst request: IRequest = {\n\t\t\t\turl: this.absolutePath,\n\t\t\t\theaders: { [RuntimeHeaders.viaHandle]: true },\n\t\t\t};\n\t\t\tthis.objectP = this.routeContext.resolveHandle(request).then<FluidObject>((response) => {\n\t\t\t\tif (response.mimeType === \"fluid/object\") {\n\t\t\t\t\tconst fluidObject: FluidObject = response.value as FluidObject;\n\t\t\t\t\treturn fluidObject;\n\t\t\t\t}\n\t\t\t\tthrow responseToException(response, request);\n\t\t\t});\n\t\t}\n\t\treturn this.objectP;\n\t}\n\n\tpublic attachGraph(): void {\n\t\treturn;\n\t}\n\n\tpublic bind(handle: IFluidHandleInternal): void {\n\t\thandle.attachGraph();\n\t}\n}\n"]}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { RuntimeHeaders } from "@fluidframework/container-runtime/internal";
|
|
7
|
-
import { FluidObject, IRequest } from "@fluidframework/core-interfaces";
|
|
8
|
-
import {
|
|
9
|
-
IFluidHandleContext,
|
|
10
|
-
type IFluidHandleInternal,
|
|
11
|
-
} from "@fluidframework/core-interfaces/internal";
|
|
12
|
-
import { assert } from "@fluidframework/core-utils/internal";
|
|
13
|
-
import { FluidHandleBase, responseToException } from "@fluidframework/runtime-utils/internal";
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* This handle is used to dynamically load a Fluid object on a remote client and is created on parsing a serialized
|
|
17
|
-
* FluidObjectHandle.
|
|
18
|
-
* This class is used to generate an IFluidHandle when de-serializing any all handles (including handles to DDSes,
|
|
19
|
-
* custom objects) that are stored in SharedObjects. The Data Store or SharedObject corresponding to the
|
|
20
|
-
* IFluidHandle can be retrieved by calling `get` on it.
|
|
21
|
-
*/
|
|
22
|
-
export class RemoteFluidObjectHandle extends FluidHandleBase<FluidObject> {
|
|
23
|
-
public readonly isAttached = true;
|
|
24
|
-
private objectP: Promise<FluidObject> | undefined;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Creates a new RemoteFluidObjectHandle when parsing an IFluidHandle.
|
|
28
|
-
* @param absolutePath - The absolute path to the handle from the container runtime.
|
|
29
|
-
* @param routeContext - The root IFluidHandleContext that has a route to this handle.
|
|
30
|
-
*/
|
|
31
|
-
constructor(
|
|
32
|
-
public readonly absolutePath: string,
|
|
33
|
-
public readonly routeContext: IFluidHandleContext,
|
|
34
|
-
) {
|
|
35
|
-
super();
|
|
36
|
-
assert(
|
|
37
|
-
absolutePath.startsWith("/"),
|
|
38
|
-
0x19d /* "Handles should always have absolute paths" */,
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
public async get(): Promise<FluidObject> {
|
|
43
|
-
if (this.objectP === undefined) {
|
|
44
|
-
// Add `viaHandle` header to distinguish from requests from non-handle paths.
|
|
45
|
-
const request: IRequest = {
|
|
46
|
-
url: this.absolutePath,
|
|
47
|
-
headers: { [RuntimeHeaders.viaHandle]: true },
|
|
48
|
-
};
|
|
49
|
-
this.objectP = this.routeContext.resolveHandle(request).then<FluidObject>((response) => {
|
|
50
|
-
if (response.mimeType === "fluid/object") {
|
|
51
|
-
const fluidObject: FluidObject = response.value as FluidObject;
|
|
52
|
-
return fluidObject;
|
|
53
|
-
}
|
|
54
|
-
throw responseToException(response, request);
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
return this.objectP;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
public attachGraph(): void {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
public bind(handle: IFluidHandleInternal): void {
|
|
65
|
-
handle.attachGraph();
|
|
66
|
-
}
|
|
67
|
-
}
|