-
Notifications
You must be signed in to change notification settings - Fork 535
/
Copy pathserializer.ts
44 lines (37 loc) · 1.55 KB
/
serializer.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*!
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
* Licensed under the MIT License.
*/
import { IFluidHandle } from "./handles";
/**
* JSON serialized form of an IFluidHandle
*/
export interface ISerializedHandle {
// Marker to indicate to JSON.parse that the object is a Fluid handle
type: "__fluid_handle__";
// URL to the object. Relative URLs are relative to the handle context passed to the stringify.
url: string;
}
export const IFluidSerializer: keyof IProvideFluidSerializer = "IFluidSerializer";
export interface IProvideFluidSerializer {
readonly IFluidSerializer: IFluidSerializer;
}
export interface IFluidSerializer extends IProvideFluidSerializer {
/**
* Given a mostly-plain object that may have handle objects embedded within, will return a fully-plain object
* where any embedded IFluidHandles have been replaced with a serializable form.
*
* The original `input` object is not mutated. This method will shallowly clones all objects in the path from
* the root to any replaced handles. (If no handles are found, returns the original object.)
*/
replaceHandles(value: any, bind: IFluidHandle): any;
/**
* Stringifies a given value. Converts any IFluidHandle to its stringified equivalent.
*/
stringify(value: any, bind: IFluidHandle): string;
/**
* Parses the given JSON input string and returns the JavaScript object defined by it. Any Fluid
* handles will be realized as part of the parse
*/
parse(value: string): any;
}