@fluidframework/core-interfaces 2.32.0 → 2.33.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/api-report/core-interfaces.legacy.alpha.api.md +9 -9
- package/dist/deepReadonly.d.ts +56 -0
- package/dist/deepReadonly.d.ts.map +1 -0
- package/dist/deepReadonly.js +7 -0
- package/dist/deepReadonly.js.map +1 -0
- package/dist/exposedInternalUtilityTypes.d.ts +168 -3
- package/dist/exposedInternalUtilityTypes.d.ts.map +1 -1
- package/dist/exposedInternalUtilityTypes.js.map +1 -1
- package/dist/exposedUtilityTypes.d.ts +4 -2
- package/dist/exposedUtilityTypes.d.ts.map +1 -1
- package/dist/exposedUtilityTypes.js.map +1 -1
- package/dist/handles.d.ts +12 -0
- package/dist/handles.d.ts.map +1 -1
- package/dist/handles.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +10 -1
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js.map +1 -1
- package/dist/jsonType.d.ts +28 -0
- package/dist/jsonType.d.ts.map +1 -1
- package/dist/jsonType.js.map +1 -1
- package/dist/shallowReadonly.d.ts +48 -0
- package/dist/shallowReadonly.d.ts.map +1 -0
- package/dist/shallowReadonly.js +7 -0
- package/dist/shallowReadonly.js.map +1 -0
- package/lib/deepReadonly.d.ts +56 -0
- package/lib/deepReadonly.d.ts.map +1 -0
- package/lib/deepReadonly.js +6 -0
- package/lib/deepReadonly.js.map +1 -0
- package/lib/exposedInternalUtilityTypes.d.ts +168 -3
- package/lib/exposedInternalUtilityTypes.d.ts.map +1 -1
- package/lib/exposedInternalUtilityTypes.js.map +1 -1
- package/lib/exposedUtilityTypes.d.ts +4 -2
- package/lib/exposedUtilityTypes.d.ts.map +1 -1
- package/lib/exposedUtilityTypes.js.map +1 -1
- package/lib/handles.d.ts +12 -0
- package/lib/handles.d.ts.map +1 -1
- package/lib/handles.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/internal.d.ts +10 -1
- package/lib/internal.d.ts.map +1 -1
- package/lib/internal.js.map +1 -1
- package/lib/jsonType.d.ts +28 -0
- package/lib/jsonType.d.ts.map +1 -1
- package/lib/jsonType.js.map +1 -1
- package/lib/shallowReadonly.d.ts +48 -0
- package/lib/shallowReadonly.d.ts.map +1 -0
- package/lib/shallowReadonly.js +6 -0
- package/lib/shallowReadonly.js.map +1 -0
- package/lib/tsdoc-metadata.json +1 -1
- package/package.json +3 -3
- package/src/deepReadonly.ts +76 -0
- package/src/exposedInternalUtilityTypes.ts +452 -5
- package/src/exposedUtilityTypes.ts +11 -2
- package/src/handles.ts +16 -0
- package/src/index.ts +1 -0
- package/src/internal.ts +15 -1
- package/src/jsonType.ts +36 -0
- package/src/shallowReadonly.ts +60 -0
package/src/jsonType.ts
CHANGED
|
@@ -35,3 +35,39 @@ export type JsonTypeWith<T> =
|
|
|
35
35
|
export type NonNullJsonObjectWith<T> =
|
|
36
36
|
| { [key: string | number]: JsonTypeWith<T> }
|
|
37
37
|
| JsonTypeWith<T>[];
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Deeply immutable type that is encodable as JSON and deserializable from JSON.
|
|
41
|
+
*
|
|
42
|
+
* @typeParam TReadonlyAlternates - Additional [immutable] types that are supported.
|
|
43
|
+
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* If `TReadonlyAlternates` is allowed as-is. So if it is not immutable, then result type
|
|
46
|
+
* is not wholly immutable.
|
|
47
|
+
*
|
|
48
|
+
* A `const` variable is still required to avoid top-level mutability. I.e.
|
|
49
|
+
* ```typescript
|
|
50
|
+
* let x: ReadonlyJsonTypeWith<never> = { a: 1 };
|
|
51
|
+
* ```
|
|
52
|
+
* does not prevent later `x = 5`. (Does prevent `x.a = 2`.)
|
|
53
|
+
*
|
|
54
|
+
* @beta
|
|
55
|
+
*/
|
|
56
|
+
export type ReadonlyJsonTypeWith<TReadonlyAlternates> =
|
|
57
|
+
// eslint-disable-next-line @rushstack/no-new-null
|
|
58
|
+
| null
|
|
59
|
+
| boolean
|
|
60
|
+
| number
|
|
61
|
+
| string
|
|
62
|
+
| TReadonlyAlternates
|
|
63
|
+
| { readonly [key: string | number]: ReadonlyJsonTypeWith<TReadonlyAlternates> }
|
|
64
|
+
| readonly ReadonlyJsonTypeWith<TReadonlyAlternates>[];
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Portion of {@link ReadonlyJsonTypeWith} that is an object (including array) and not null.
|
|
68
|
+
*
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
export type ReadonlyNonNullJsonObjectWith<TReadonlyAlternates> =
|
|
72
|
+
| { readonly [key: string | number]: ReadonlyJsonTypeWith<TReadonlyAlternates> }
|
|
73
|
+
| readonly ReadonlyJsonTypeWith<TReadonlyAlternates>[];
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
InternalUtilityTypes,
|
|
8
|
+
ReadonlySupportedGenerics,
|
|
9
|
+
} from "./exposedInternalUtilityTypes.js";
|
|
10
|
+
import type { IFluidHandle } from "./handles.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Default set of generic that {@link ShallowReadonly} will apply shallow immutability
|
|
14
|
+
* to generic types.
|
|
15
|
+
*
|
|
16
|
+
* @privateRemarks
|
|
17
|
+
* WeakRef should be added when lib is updated to ES2021 or later.
|
|
18
|
+
*
|
|
19
|
+
* @system
|
|
20
|
+
*/
|
|
21
|
+
export type ShallowReadonlySupportedGenericsDefault = Promise<unknown> | IFluidHandle;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Options for {@link ShallowReadonly}.
|
|
25
|
+
*
|
|
26
|
+
* @beta
|
|
27
|
+
*/
|
|
28
|
+
export interface ShallowReadonlyOptions {
|
|
29
|
+
/**
|
|
30
|
+
* Union of Built-in and IFluidHandle whose generics will also be made shallowly immutable.
|
|
31
|
+
*
|
|
32
|
+
* The default value is `IFluidHandle` | `Promise`.
|
|
33
|
+
*/
|
|
34
|
+
DeepenedGenerics?: ReadonlySupportedGenerics;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Transforms type to a shallowly immutable type.
|
|
39
|
+
*
|
|
40
|
+
* @remarks
|
|
41
|
+
* This utility type is similar to `Readonly<T>`, but also applies immutability to
|
|
42
|
+
* common generic types like `Map` and `Set`.
|
|
43
|
+
*
|
|
44
|
+
* Optionally, immutability can be applied to supported generics types. See
|
|
45
|
+
* {@link ShallowReadonlySupportedGenericsDefault} for generics that have
|
|
46
|
+
* immutability applied to generic type by default.
|
|
47
|
+
*
|
|
48
|
+
* @beta
|
|
49
|
+
*/
|
|
50
|
+
export type ShallowReadonly<
|
|
51
|
+
T,
|
|
52
|
+
Options extends ShallowReadonlyOptions = {
|
|
53
|
+
DeepenedGenerics: ShallowReadonlySupportedGenericsDefault;
|
|
54
|
+
},
|
|
55
|
+
> = InternalUtilityTypes.ShallowReadonlyImpl<
|
|
56
|
+
T,
|
|
57
|
+
Options extends { DeepenedGenerics: unknown }
|
|
58
|
+
? Options["DeepenedGenerics"]
|
|
59
|
+
: ShallowReadonlySupportedGenericsDefault
|
|
60
|
+
>;
|