@fluidframework/presence 2.92.0 → 2.93.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/README.md +4 -4
- package/dist/alpha.d.ts +6 -4
- package/dist/beta.d.ts +5 -2
- package/dist/getPresence.d.ts +4 -9
- package/dist/getPresence.d.ts.map +1 -1
- package/dist/getPresence.js +6 -86
- package/dist/getPresence.js.map +1 -1
- package/dist/index.d.ts +4 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/legacy.alpha.d.ts +6 -4
- package/dist/package.json +1 -15
- package/dist/public.d.ts +69 -0
- package/lib/alpha.d.ts +6 -4
- package/lib/beta.d.ts +5 -2
- package/lib/getPresence.d.ts +4 -9
- package/lib/getPresence.d.ts.map +1 -1
- package/lib/getPresence.js +6 -85
- package/lib/getPresence.js.map +1 -1
- package/lib/index.d.ts +4 -13
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -4
- package/lib/index.js.map +1 -1
- package/lib/legacy.alpha.d.ts +6 -4
- package/lib/public.d.ts +69 -0
- package/package.json +27 -76
- package/dist/baseTypes.d.ts +0 -24
- package/dist/baseTypes.d.ts.map +0 -1
- package/dist/baseTypes.js +0 -7
- package/dist/baseTypes.js.map +0 -1
- package/dist/broadcastControls.d.ts +0 -37
- package/dist/broadcastControls.d.ts.map +0 -1
- package/dist/broadcastControls.js +0 -60
- package/dist/broadcastControls.js.map +0 -1
- package/dist/broadcastControlsTypes.d.ts +0 -38
- package/dist/broadcastControlsTypes.d.ts.map +0 -1
- package/dist/broadcastControlsTypes.js +0 -7
- package/dist/broadcastControlsTypes.js.map +0 -1
- package/dist/exposedInternalTypes.d.ts +0 -138
- package/dist/exposedInternalTypes.d.ts.map +0 -1
- package/dist/exposedInternalTypes.js +0 -19
- package/dist/exposedInternalTypes.js.map +0 -1
- package/dist/exposedUtilityTypes.d.ts +0 -108
- package/dist/exposedUtilityTypes.d.ts.map +0 -1
- package/dist/exposedUtilityTypes.js +0 -7
- package/dist/exposedUtilityTypes.js.map +0 -1
- package/dist/internalUtils.d.ts +0 -125
- package/dist/internalUtils.d.ts.map +0 -1
- package/dist/internalUtils.js +0 -99
- package/dist/internalUtils.js.map +0 -1
- package/dist/latestMapTypes.d.ts +0 -343
- package/dist/latestMapTypes.d.ts.map +0 -1
- package/dist/latestMapTypes.js +0 -7
- package/dist/latestMapTypes.js.map +0 -1
- package/dist/latestMapValueManager.d.ts +0 -52
- package/dist/latestMapValueManager.d.ts.map +0 -1
- package/dist/latestMapValueManager.js +0 -250
- package/dist/latestMapValueManager.js.map +0 -1
- package/dist/latestTypes.d.ts +0 -183
- package/dist/latestTypes.d.ts.map +0 -1
- package/dist/latestTypes.js +0 -7
- package/dist/latestTypes.js.map +0 -1
- package/dist/latestValueManager.d.ts +0 -10
- package/dist/latestValueManager.d.ts.map +0 -1
- package/dist/latestValueManager.js +0 -117
- package/dist/latestValueManager.js.map +0 -1
- package/dist/latestValueTypes.d.ts +0 -108
- package/dist/latestValueTypes.d.ts.map +0 -1
- package/dist/latestValueTypes.js +0 -7
- package/dist/latestValueTypes.js.map +0 -1
- package/dist/notificationsManager.d.ts +0 -27
- package/dist/notificationsManager.d.ts.map +0 -1
- package/dist/notificationsManager.js +0 -98
- package/dist/notificationsManager.js.map +0 -1
- package/dist/notificationsManagerTypes.d.ts +0 -144
- package/dist/notificationsManagerTypes.d.ts.map +0 -1
- package/dist/notificationsManagerTypes.js +0 -7
- package/dist/notificationsManagerTypes.js.map +0 -1
- package/dist/packageVersion.d.ts +0 -9
- package/dist/packageVersion.d.ts.map +0 -1
- package/dist/packageVersion.js +0 -12
- package/dist/packageVersion.js.map +0 -1
- package/dist/presence.d.ts +0 -229
- package/dist/presence.d.ts.map +0 -1
- package/dist/presence.js +0 -23
- package/dist/presence.js.map +0 -1
- package/dist/presenceDatastoreManager.d.ts +0 -149
- package/dist/presenceDatastoreManager.d.ts.map +0 -1
- package/dist/presenceDatastoreManager.js +0 -667
- package/dist/presenceDatastoreManager.js.map +0 -1
- package/dist/presenceManager.d.ts +0 -16
- package/dist/presenceManager.d.ts.map +0 -1
- package/dist/presenceManager.js +0 -140
- package/dist/presenceManager.js.map +0 -1
- package/dist/presenceStates.d.ts +0 -102
- package/dist/presenceStates.d.ts.map +0 -1
- package/dist/presenceStates.js +0 -231
- package/dist/presenceStates.js.map +0 -1
- package/dist/protocol.d.ts +0 -111
- package/dist/protocol.d.ts.map +0 -1
- package/dist/protocol.js +0 -20
- package/dist/protocol.js.map +0 -1
- package/dist/runtimeTypes.d.ts +0 -26
- package/dist/runtimeTypes.d.ts.map +0 -1
- package/dist/runtimeTypes.js +0 -7
- package/dist/runtimeTypes.js.map +0 -1
- package/dist/stateDatastore.d.ts +0 -56
- package/dist/stateDatastore.d.ts.map +0 -1
- package/dist/stateDatastore.js +0 -22
- package/dist/stateDatastore.js.map +0 -1
- package/dist/stateFactory.d.ts +0 -18
- package/dist/stateFactory.d.ts.map +0 -1
- package/dist/stateFactory.js +0 -23
- package/dist/stateFactory.js.map +0 -1
- package/dist/statesManagerTypes.d.ts +0 -27
- package/dist/statesManagerTypes.d.ts.map +0 -1
- package/dist/statesManagerTypes.js +0 -7
- package/dist/statesManagerTypes.js.map +0 -1
- package/dist/systemWorkspace.d.ts +0 -58
- package/dist/systemWorkspace.d.ts.map +0 -1
- package/dist/systemWorkspace.js +0 -265
- package/dist/systemWorkspace.js.map +0 -1
- package/dist/timerManager.d.ts +0 -37
- package/dist/timerManager.d.ts.map +0 -1
- package/dist/timerManager.js +0 -65
- package/dist/timerManager.js.map +0 -1
- package/dist/types.d.ts +0 -132
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -7
- package/dist/types.js.map +0 -1
- package/dist/validatableTypes.d.ts +0 -69
- package/dist/validatableTypes.d.ts.map +0 -1
- package/dist/validatableTypes.js +0 -7
- package/dist/validatableTypes.js.map +0 -1
- package/dist/validatedGetter.d.ts +0 -18
- package/dist/validatedGetter.d.ts.map +0 -1
- package/dist/validatedGetter.js +0 -43
- package/dist/validatedGetter.js.map +0 -1
- package/dist/valueManager.d.ts +0 -15
- package/dist/valueManager.d.ts.map +0 -1
- package/dist/valueManager.js +0 -22
- package/dist/valueManager.js.map +0 -1
- package/lib/baseTypes.d.ts +0 -24
- package/lib/baseTypes.d.ts.map +0 -1
- package/lib/baseTypes.js +0 -6
- package/lib/baseTypes.js.map +0 -1
- package/lib/broadcastControls.d.ts +0 -37
- package/lib/broadcastControls.d.ts.map +0 -1
- package/lib/broadcastControls.js +0 -55
- package/lib/broadcastControls.js.map +0 -1
- package/lib/broadcastControlsTypes.d.ts +0 -38
- package/lib/broadcastControlsTypes.d.ts.map +0 -1
- package/lib/broadcastControlsTypes.js +0 -6
- package/lib/broadcastControlsTypes.js.map +0 -1
- package/lib/exposedInternalTypes.d.ts +0 -138
- package/lib/exposedInternalTypes.d.ts.map +0 -1
- package/lib/exposedInternalTypes.js +0 -16
- package/lib/exposedInternalTypes.js.map +0 -1
- package/lib/exposedUtilityTypes.d.ts +0 -108
- package/lib/exposedUtilityTypes.d.ts.map +0 -1
- package/lib/exposedUtilityTypes.js +0 -6
- package/lib/exposedUtilityTypes.js.map +0 -1
- package/lib/internalUtils.d.ts +0 -125
- package/lib/internalUtils.d.ts.map +0 -1
- package/lib/internalUtils.js +0 -90
- package/lib/internalUtils.js.map +0 -1
- package/lib/latestMapTypes.d.ts +0 -343
- package/lib/latestMapTypes.d.ts.map +0 -1
- package/lib/latestMapTypes.js +0 -6
- package/lib/latestMapTypes.js.map +0 -1
- package/lib/latestMapValueManager.d.ts +0 -52
- package/lib/latestMapValueManager.d.ts.map +0 -1
- package/lib/latestMapValueManager.js +0 -246
- package/lib/latestMapValueManager.js.map +0 -1
- package/lib/latestTypes.d.ts +0 -183
- package/lib/latestTypes.d.ts.map +0 -1
- package/lib/latestTypes.js +0 -6
- package/lib/latestTypes.js.map +0 -1
- package/lib/latestValueManager.d.ts +0 -10
- package/lib/latestValueManager.d.ts.map +0 -1
- package/lib/latestValueManager.js +0 -113
- package/lib/latestValueManager.js.map +0 -1
- package/lib/latestValueTypes.d.ts +0 -108
- package/lib/latestValueTypes.d.ts.map +0 -1
- package/lib/latestValueTypes.js +0 -6
- package/lib/latestValueTypes.js.map +0 -1
- package/lib/notificationsManager.d.ts +0 -27
- package/lib/notificationsManager.d.ts.map +0 -1
- package/lib/notificationsManager.js +0 -94
- package/lib/notificationsManager.js.map +0 -1
- package/lib/notificationsManagerTypes.d.ts +0 -144
- package/lib/notificationsManagerTypes.d.ts.map +0 -1
- package/lib/notificationsManagerTypes.js +0 -6
- package/lib/notificationsManagerTypes.js.map +0 -1
- package/lib/packageVersion.d.ts +0 -9
- package/lib/packageVersion.d.ts.map +0 -1
- package/lib/packageVersion.js +0 -9
- package/lib/packageVersion.js.map +0 -1
- package/lib/presence.d.ts +0 -229
- package/lib/presence.d.ts.map +0 -1
- package/lib/presence.js +0 -20
- package/lib/presence.js.map +0 -1
- package/lib/presenceDatastoreManager.d.ts +0 -149
- package/lib/presenceDatastoreManager.d.ts.map +0 -1
- package/lib/presenceDatastoreManager.js +0 -663
- package/lib/presenceDatastoreManager.js.map +0 -1
- package/lib/presenceManager.d.ts +0 -16
- package/lib/presenceManager.d.ts.map +0 -1
- package/lib/presenceManager.js +0 -136
- package/lib/presenceManager.js.map +0 -1
- package/lib/presenceStates.d.ts +0 -102
- package/lib/presenceStates.d.ts.map +0 -1
- package/lib/presenceStates.js +0 -225
- package/lib/presenceStates.js.map +0 -1
- package/lib/protocol.d.ts +0 -111
- package/lib/protocol.d.ts.map +0 -1
- package/lib/protocol.js +0 -17
- package/lib/protocol.js.map +0 -1
- package/lib/runtimeTypes.d.ts +0 -26
- package/lib/runtimeTypes.d.ts.map +0 -1
- package/lib/runtimeTypes.js +0 -6
- package/lib/runtimeTypes.js.map +0 -1
- package/lib/stateDatastore.d.ts +0 -56
- package/lib/stateDatastore.d.ts.map +0 -1
- package/lib/stateDatastore.js +0 -17
- package/lib/stateDatastore.js.map +0 -1
- package/lib/stateFactory.d.ts +0 -18
- package/lib/stateFactory.d.ts.map +0 -1
- package/lib/stateFactory.js +0 -20
- package/lib/stateFactory.js.map +0 -1
- package/lib/statesManagerTypes.d.ts +0 -27
- package/lib/statesManagerTypes.d.ts.map +0 -1
- package/lib/statesManagerTypes.js +0 -6
- package/lib/statesManagerTypes.js.map +0 -1
- package/lib/systemWorkspace.d.ts +0 -58
- package/lib/systemWorkspace.d.ts.map +0 -1
- package/lib/systemWorkspace.js +0 -261
- package/lib/systemWorkspace.js.map +0 -1
- package/lib/timerManager.d.ts +0 -37
- package/lib/timerManager.d.ts.map +0 -1
- package/lib/timerManager.js +0 -61
- package/lib/timerManager.js.map +0 -1
- package/lib/types.d.ts +0 -132
- package/lib/types.d.ts.map +0 -1
- package/lib/types.js +0 -6
- package/lib/types.js.map +0 -1
- package/lib/validatableTypes.d.ts +0 -69
- package/lib/validatableTypes.d.ts.map +0 -1
- package/lib/validatableTypes.js +0 -6
- package/lib/validatableTypes.js.map +0 -1
- package/lib/validatedGetter.d.ts +0 -18
- package/lib/validatedGetter.d.ts.map +0 -1
- package/lib/validatedGetter.js +0 -39
- package/lib/validatedGetter.js.map +0 -1
- package/lib/valueManager.d.ts +0 -15
- package/lib/valueManager.d.ts.map +0 -1
- package/lib/valueManager.js +0 -17
- package/lib/valueManager.js.map +0 -1
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import type { OpaqueJsonDeserialized } from "@fluidframework/core-interfaces/internal/exposedUtilityTypes";
|
|
6
|
-
/**
|
|
7
|
-
* Collection of value types that are not intended to be used/imported
|
|
8
|
-
* directly outside of this package.
|
|
9
|
-
*
|
|
10
|
-
* @beta
|
|
11
|
-
* @system
|
|
12
|
-
*/
|
|
13
|
-
export declare namespace InternalTypes {
|
|
14
|
-
/**
|
|
15
|
-
* Metadata for a value state.
|
|
16
|
-
*
|
|
17
|
-
* @system
|
|
18
|
-
*/
|
|
19
|
-
interface ValueStateMetadata {
|
|
20
|
-
rev: number;
|
|
21
|
-
timestamp: number;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Represents a state that may have a value.
|
|
25
|
-
* And it includes standard metadata.
|
|
26
|
-
*
|
|
27
|
-
* @remarks
|
|
28
|
-
* See {@link InternalPresenceTypes.ValueRequiredState}.
|
|
29
|
-
*
|
|
30
|
-
* @system
|
|
31
|
-
*/
|
|
32
|
-
interface ValueOptionalState<TValue> extends ValueStateMetadata {
|
|
33
|
-
value?: OpaqueJsonDeserialized<TValue>;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Represents a state that must have a value.
|
|
37
|
-
* And it includes standard metadata.
|
|
38
|
-
*
|
|
39
|
-
* @remarks
|
|
40
|
-
* The value is wrapped in `OpaqueJsonDeserialized` as uses are expected
|
|
41
|
-
* to involve generic or unknown types that will be filtered. It is here
|
|
42
|
-
* mostly as a convenience to the many such uses that would otherwise
|
|
43
|
-
* need to specify some wrapper themselves.
|
|
44
|
-
*
|
|
45
|
-
* For known cases, construct a custom interface that extends
|
|
46
|
-
* {@link InternalPresenceTypes.ValueStateMetadata}.
|
|
47
|
-
*
|
|
48
|
-
* @system
|
|
49
|
-
*/
|
|
50
|
-
interface ValueRequiredState<TValue> extends ValueStateMetadata {
|
|
51
|
-
value: OpaqueJsonDeserialized<TValue>;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* A directory of values, where each value may be an optional state or another directory.
|
|
55
|
-
*
|
|
56
|
-
* @system
|
|
57
|
-
*/
|
|
58
|
-
interface ValueDirectory<T> {
|
|
59
|
-
rev: number;
|
|
60
|
-
items: {
|
|
61
|
-
[name: string | number]: ValueOptionalState<T> | ValueDirectory<T>;
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Convenience type for a required state or a directory of values.
|
|
66
|
-
*
|
|
67
|
-
* @system
|
|
68
|
-
*/
|
|
69
|
-
type ValueDirectoryOrState<T> = ValueRequiredState<T> | ValueDirectory<T>;
|
|
70
|
-
/**
|
|
71
|
-
* Collection of optional values in a "map" structure.
|
|
72
|
-
*
|
|
73
|
-
* @system
|
|
74
|
-
*/
|
|
75
|
-
interface MapValueState<T, Keys extends string> {
|
|
76
|
-
rev: number;
|
|
77
|
-
items: {
|
|
78
|
-
[name in Keys]: ValueOptionalState<T>;
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Opaque type representing internal state datastore.
|
|
83
|
-
*
|
|
84
|
-
* @system
|
|
85
|
-
*/
|
|
86
|
-
class StateDatastoreHandle<TKey, TValue extends ValueDirectoryOrState<unknown>> {
|
|
87
|
-
private readonly StateDatastoreHandle;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Brand to ensure state values internal type safety without revealing
|
|
91
|
-
* internals that are subject to change.
|
|
92
|
-
*
|
|
93
|
-
* @system
|
|
94
|
-
*/
|
|
95
|
-
class StateValueBrand<T> {
|
|
96
|
-
private readonly StateValue;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* This type provides no additional functionality over the type it wraps.
|
|
100
|
-
* It is used to ensure type safety within package.
|
|
101
|
-
* Users may find it convenient to just use the type it wraps directly.
|
|
102
|
-
*
|
|
103
|
-
* @privateRemarks
|
|
104
|
-
* Checkout filtering omitting unknown from T (`Omit<T,unknown> &`).
|
|
105
|
-
*
|
|
106
|
-
* @system
|
|
107
|
-
*/
|
|
108
|
-
type StateValue<T> = T & StateValueBrand<T>;
|
|
109
|
-
/**
|
|
110
|
-
* Package internal function declaration for state and notification instantiation.
|
|
111
|
-
*
|
|
112
|
-
* @remarks
|
|
113
|
-
* Direct use of this type is discouraged. If in need, try to use the type
|
|
114
|
-
* returned by the factory functions instead, as those are more specific and
|
|
115
|
-
* stable.
|
|
116
|
-
*
|
|
117
|
-
* @system
|
|
118
|
-
*/
|
|
119
|
-
type ManagerFactory<TKey extends string, TValue extends ValueDirectoryOrState<unknown>, TManager> = {
|
|
120
|
-
instanceBase: new (...args: any[]) => unknown;
|
|
121
|
-
} & ((key: TKey, datastoreHandle: StateDatastoreHandle<TKey, TValue>) => {
|
|
122
|
-
initialData?: {
|
|
123
|
-
value: TValue;
|
|
124
|
-
allowableUpdateLatencyMs: number | undefined;
|
|
125
|
-
};
|
|
126
|
-
manager: StateValue<TManager>;
|
|
127
|
-
});
|
|
128
|
-
/**
|
|
129
|
-
* Structure of a generic notification "value".
|
|
130
|
-
*
|
|
131
|
-
* @system
|
|
132
|
-
*/
|
|
133
|
-
interface NotificationType {
|
|
134
|
-
name: string;
|
|
135
|
-
args: unknown[];
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
//# sourceMappingURL=exposedInternalTypes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exposedInternalTypes.d.ts","sourceRoot":"","sources":["../src/exposedInternalTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8DAA8D,CAAC;AAE3G;;;;;;GAMG;AAEH,yBAAiB,aAAa,CAAC;IAC9B;;;;OAIG;IACH,UAAiB,kBAAkB;QAClC,GAAG,EAAE,MAAM,CAAC;QACZ,SAAS,EAAE,MAAM,CAAC;KAClB;IAED;;;;;;;;OAQG;IACH,UAAiB,kBAAkB,CAAC,MAAM,CAAE,SAAQ,kBAAkB;QACrE,KAAK,CAAC,EAAE,sBAAsB,CAAC,MAAM,CAAC,CAAC;KAMvC;IAED;;;;;;;;;;;;;;OAcG;IACH,UAAiB,kBAAkB,CAAC,MAAM,CAAE,SAAQ,kBAAkB;QACrE,KAAK,EAAE,sBAAsB,CAAC,MAAM,CAAC,CAAC;KAMtC;IAED;;;;OAIG;IACH,UAAiB,c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AS,CAAA;SAAE,CAAC;QAC9E,OAAO,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;KAC9B,CAAC,CAAC;IAEH;;;;OAIG;IACH,UAAiB,gBAAgB;QAChC,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,OAAO,EAAE,CAAC;KAChB;CACD"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Collection of value types that are not intended to be used/imported
|
|
7
|
-
* directly outside of this package.
|
|
8
|
-
*
|
|
9
|
-
* @beta
|
|
10
|
-
* @system
|
|
11
|
-
*/
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
13
|
-
export var InternalTypes;
|
|
14
|
-
(function (InternalTypes) {
|
|
15
|
-
})(InternalTypes || (InternalTypes = {}));
|
|
16
|
-
//# sourceMappingURL=exposedInternalTypes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exposedInternalTypes.js","sourceRoot":"","sources":["../src/exposedInternalTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;;;GAMG;AACH,2DAA2D;AAC3D,MAAM,KAAW,aAAa,CA2J7B;AA3JD,WAAiB,aAAa;AA2J9B,CAAC,EA3JgB,aAAa,KAAb,aAAa,QA2J7B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { OpaqueJsonDeserialized } from \"@fluidframework/core-interfaces/internal/exposedUtilityTypes\";\n\n/**\n * Collection of value types that are not intended to be used/imported\n * directly outside of this package.\n *\n * @beta\n * @system\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace InternalTypes {\n\t/**\n\t * Metadata for a value state.\n\t *\n\t * @system\n\t */\n\texport interface ValueStateMetadata {\n\t\trev: number;\n\t\ttimestamp: number;\n\t}\n\n\t/**\n\t * Represents a state that may have a value.\n\t * And it includes standard metadata.\n\t *\n\t * @remarks\n\t * See {@link InternalPresenceTypes.ValueRequiredState}.\n\t *\n\t * @system\n\t */\n\texport interface ValueOptionalState<TValue> extends ValueStateMetadata {\n\t\tvalue?: OpaqueJsonDeserialized<TValue>;\n\n\t\t// Uncomment this property and rebuild to check more thoroughly\n\t\t// for incompatibilities between this non-validatable state\n\t\t// and ValidatableOptionalState.\n\t\t// validatedValue?: never;\n\t}\n\n\t/**\n\t * Represents a state that must have a value.\n\t * And it includes standard metadata.\n\t *\n\t * @remarks\n\t * The value is wrapped in `OpaqueJsonDeserialized` as uses are expected\n\t * to involve generic or unknown types that will be filtered. It is here\n\t * mostly as a convenience to the many such uses that would otherwise\n\t * need to specify some wrapper themselves.\n\t *\n\t * For known cases, construct a custom interface that extends\n\t * {@link InternalPresenceTypes.ValueStateMetadata}.\n\t *\n\t * @system\n\t */\n\texport interface ValueRequiredState<TValue> extends ValueStateMetadata {\n\t\tvalue: OpaqueJsonDeserialized<TValue>;\n\n\t\t// Uncomment this property and rebuild to check more thoroughly\n\t\t// for incompatibilities between this non-validatable state\n\t\t// and ValidatableOptionalState.\n\t\t// validatedValue?: never;\n\t}\n\n\t/**\n\t * A directory of values, where each value may be an optional state or another directory.\n\t *\n\t * @system\n\t */\n\texport interface ValueDirectory<T> {\n\t\trev: number;\n\t\titems: {\n\t\t\t// Caution: any particular item may or may not exist\n\t\t\t// Typescript does not support absent keys without forcing type to also be undefined.\n\t\t\t// See https://github.com/microsoft/TypeScript/issues/42810.\n\t\t\t[name: string | number]: ValueOptionalState<T> | ValueDirectory<T>;\n\t\t};\n\t}\n\n\t/**\n\t * Convenience type for a required state or a directory of values.\n\t *\n\t * @system\n\t */\n\texport type ValueDirectoryOrState<T> = ValueRequiredState<T> | ValueDirectory<T>;\n\n\t/**\n\t * Collection of optional values in a \"map\" structure.\n\t *\n\t * @system\n\t */\n\texport interface MapValueState<T, Keys extends string> {\n\t\trev: number;\n\t\titems: {\n\t\t\t// Caution: any particular item may or may not exist\n\t\t\t// Typescript does not support absent keys without forcing type to also be undefined.\n\t\t\t// See https://github.com/microsoft/TypeScript/issues/42810.\n\t\t\t[name in Keys]: ValueOptionalState<T>;\n\t\t};\n\t}\n\n\t/**\n\t * Opaque type representing internal state datastore.\n\t *\n\t * @system\n\t */\n\texport declare class StateDatastoreHandle<\n\t\tTKey,\n\t\tTValue extends ValueDirectoryOrState<unknown>,\n\t> {\n\t\tprivate readonly StateDatastoreHandle: StateDatastoreHandle<TKey, TValue>;\n\t}\n\n\t/**\n\t * Brand to ensure state values internal type safety without revealing\n\t * internals that are subject to change.\n\t *\n\t * @system\n\t */\n\texport declare class StateValueBrand<T> {\n\t\tprivate readonly StateValue: StateValue<T>;\n\t}\n\n\t/**\n\t * This type provides no additional functionality over the type it wraps.\n\t * It is used to ensure type safety within package.\n\t * Users may find it convenient to just use the type it wraps directly.\n\t *\n\t * @privateRemarks\n\t * Checkout filtering omitting unknown from T (`Omit<T,unknown> &`).\n\t *\n\t * @system\n\t */\n\texport type StateValue<T> = T & StateValueBrand<T>;\n\n\t/**\n\t * Package internal function declaration for state and notification instantiation.\n\t *\n\t * @remarks\n\t * Direct use of this type is discouraged. If in need, try to use the type\n\t * returned by the factory functions instead, as those are more specific and\n\t * stable.\n\t *\n\t * @system\n\t */\n\texport type ManagerFactory<\n\t\tTKey extends string,\n\t\tTValue extends ValueDirectoryOrState<unknown>,\n\t\tTManager,\n\t> = { instanceBase: new (...args: any[]) => unknown } & ((\n\t\tkey: TKey,\n\t\tdatastoreHandle: StateDatastoreHandle<TKey, TValue>,\n\t) => {\n\t\tinitialData?: { value: TValue; allowableUpdateLatencyMs: number | undefined };\n\t\tmanager: StateValue<TManager>;\n\t});\n\n\t/**\n\t * Structure of a generic notification \"value\".\n\t *\n\t * @system\n\t */\n\texport interface NotificationType {\n\t\tname: string;\n\t\targs: unknown[];\n\t}\n}\n"]}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import type { InternalCoreInterfacesUtilityTypes, JsonDeserialized, JsonSerializable } from "@fluidframework/core-interfaces/internal/exposedUtilityTypes";
|
|
6
|
-
import type { Attendee } from "./presence.js";
|
|
7
|
-
/**
|
|
8
|
-
* Collection of utility types that are not intended to be used/imported
|
|
9
|
-
* directly outside of this package.
|
|
10
|
-
*
|
|
11
|
-
* @alpha
|
|
12
|
-
* @system
|
|
13
|
-
*/
|
|
14
|
-
export declare namespace InternalUtilityTypes {
|
|
15
|
-
/**
|
|
16
|
-
* Yields `IfParametersValid` when the given type is an acceptable shape for a
|
|
17
|
-
* notification. `Else` otherwise.
|
|
18
|
-
*
|
|
19
|
-
* @system
|
|
20
|
-
*/
|
|
21
|
-
type IfNotificationParametersSignature<Event, IfParametersValid, Else> = Event extends (...args: infer P) => void ? InternalCoreInterfacesUtilityTypes.IfSameType<P, JsonSerializable<P>, IfParametersValid, Else> : Else;
|
|
22
|
-
/**
|
|
23
|
-
* Yields `IfSubscriber` when the given type is an acceptable shape for a notification
|
|
24
|
-
* listener (subscriber) function. `Else` otherwise.
|
|
25
|
-
*
|
|
26
|
-
* @system
|
|
27
|
-
*/
|
|
28
|
-
type IfNotificationSubscriberSignature<Event, IfSubscriber, Else> = Event extends (sender: Attendee, ...args: infer P) => void ? InternalCoreInterfacesUtilityTypes.IfSameType<P, JsonSerializable<P>, IfSubscriber, Else> : Else;
|
|
29
|
-
/**
|
|
30
|
-
* Used to specify the kinds of notifications handled by a {@link NotificationListenable}
|
|
31
|
-
* by describing the custom parameters in a function signature.
|
|
32
|
-
*
|
|
33
|
-
* @remarks
|
|
34
|
-
*
|
|
35
|
-
* Any object type is a valid NotificationListeners, but only the notification-like
|
|
36
|
-
* properties of that type will be included.
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
*
|
|
40
|
-
* ```typescript
|
|
41
|
-
* interface MyNotifications {
|
|
42
|
-
* load: (user: string, data: IUserData) => void;
|
|
43
|
-
* requestPause: (period: number) => void;
|
|
44
|
-
* }
|
|
45
|
-
* ```
|
|
46
|
-
*
|
|
47
|
-
* @system
|
|
48
|
-
*/
|
|
49
|
-
type NotificationListeners<E> = {
|
|
50
|
-
[P in keyof E as IfNotificationParametersSignature<E[P], P, never>]: E[P];
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* Converts a notification subscriber signature into parameters signature
|
|
54
|
-
* (by removing the `sender: Attendee` parameter).
|
|
55
|
-
*
|
|
56
|
-
* @remarks
|
|
57
|
-
* No attempt is made to validate that the original signature is valid with
|
|
58
|
-
* all parameters being JSON-serializable.
|
|
59
|
-
*
|
|
60
|
-
* @system
|
|
61
|
-
*/
|
|
62
|
-
type NotificationParametersSignatureFromSubscriberSignature<Event> = Event extends (sender: Attendee, ...args: infer P) => void ? (...args: P) => void : never;
|
|
63
|
-
/**
|
|
64
|
-
* Used to specify the kinds of notifications handled by a {@link NotificationListenable}
|
|
65
|
-
* by describing the subscriber signatures.
|
|
66
|
-
*
|
|
67
|
-
* @remarks
|
|
68
|
-
*
|
|
69
|
-
* Any object type is a valid NotificationListenersWithSubscriberSignatures,
|
|
70
|
-
* but only the notification-like properties of that type will be included.
|
|
71
|
-
*
|
|
72
|
-
* @example
|
|
73
|
-
*
|
|
74
|
-
* ```typescript
|
|
75
|
-
* interface MyNotifications {
|
|
76
|
-
* load: (sender: Attendee, user: string, data: IUserData) => void;
|
|
77
|
-
* requestPause: (sender: Attendee, period: number) => void;
|
|
78
|
-
* }
|
|
79
|
-
* ```
|
|
80
|
-
*
|
|
81
|
-
* @system
|
|
82
|
-
*/
|
|
83
|
-
type NotificationListenersWithSubscriberSignatures<E> = {
|
|
84
|
-
[P in keyof E as IfNotificationSubscriberSignature<E[P], P, never>]: E[P];
|
|
85
|
-
};
|
|
86
|
-
/**
|
|
87
|
-
* Converts a record of notification subscriber signatures into
|
|
88
|
-
* a record of base parameter signatures (which are the canonical form).
|
|
89
|
-
*
|
|
90
|
-
* @system
|
|
91
|
-
*/
|
|
92
|
-
type NotificationListenersFromSubscriberSignatures<E extends NotificationListenersWithSubscriberSignatures<E>> = {
|
|
93
|
-
[K in keyof NotificationListenersWithSubscriberSignatures<E>]: NotificationParametersSignatureFromSubscriberSignature<E[K]>;
|
|
94
|
-
} extends infer TListeners ? NotificationListeners<TListeners> : never;
|
|
95
|
-
/**
|
|
96
|
-
* {@link @fluidframework/core-interfaces#JsonDeserialized} version of the parameters of a function.
|
|
97
|
-
*
|
|
98
|
-
* @system
|
|
99
|
-
*/
|
|
100
|
-
type JsonDeserializedParameters<T extends (...args: any[]) => unknown> = T extends (...args: infer P) => unknown ? JsonDeserialized<P> : never;
|
|
101
|
-
/**
|
|
102
|
-
* {@link @fluidframework/core-interfaces#JsonSerializable} version of the parameters of a function.
|
|
103
|
-
*
|
|
104
|
-
* @system
|
|
105
|
-
*/
|
|
106
|
-
type JsonSerializableParameters<T extends (...args: any[]) => unknown> = T extends (...args: infer P) => unknown ? JsonSerializable<P> : never;
|
|
107
|
-
}
|
|
108
|
-
//# sourceMappingURL=exposedUtilityTypes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exposedUtilityTypes.d.ts","sourceRoot":"","sources":["../src/exposedUtilityTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,kCAAkC,EAClC,gBAAgB,EAChB,gBAAgB,EAChB,MAAM,8DAA8D,CAAC;AAEtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C;;;;;;GAMG;AAEH,yBAAiB,oBAAoB,CAAC;IACrC;;;;;OAKG;IACH,KAAY,iCAAiC,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,IAC3E,KAAK,SAAS,CAAC,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AAsD,CACpH,CAAC,CAAC,CAAC,CAAC,CACJ;KACD,SAAS,MAAM,UAAU,GAExB,qBAAqB,CAAC,UAAU,CAAC,GAChC,KAAK,CAAC;IAET;;;;OAIG;IACH,KAAY,0BAA0B,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,IAAI,CAAC,SAAS,CACzF,GAAG,IAAI,EAAE,MAAM,CAAC,KACZ,OAAO,GACT,gBAAgB,CAAC,CAAC,CAAC,GACnB,KAAK,CAAC;IAET;;;;OAIG;IACH,KAAY,0BAA0B,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,IAAI,CAAC,SAAS,CACzF,GAAG,IAAI,EAAE,MAAM,CAAC,KACZ,OAAO,GACT,gBAAgB,CAAC,CAAC,CAAC,GACnB,KAAK,CAAC;CACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exposedUtilityTypes.js","sourceRoot":"","sources":["../src/exposedUtilityTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tInternalCoreInterfacesUtilityTypes,\n\tJsonDeserialized,\n\tJsonSerializable,\n} from \"@fluidframework/core-interfaces/internal/exposedUtilityTypes\";\n\nimport type { Attendee } from \"./presence.js\";\n\n/**\n * Collection of utility types that are not intended to be used/imported\n * directly outside of this package.\n *\n * @alpha\n * @system\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace InternalUtilityTypes {\n\t/**\n\t * Yields `IfParametersValid` when the given type is an acceptable shape for a\n\t * notification. `Else` otherwise.\n\t *\n\t * @system\n\t */\n\texport type IfNotificationParametersSignature<Event, IfParametersValid, Else> =\n\t\tEvent extends (...args: infer P) => void\n\t\t\t? InternalCoreInterfacesUtilityTypes.IfSameType<\n\t\t\t\t\tP,\n\t\t\t\t\tJsonSerializable<P>,\n\t\t\t\t\tIfParametersValid,\n\t\t\t\t\tElse\n\t\t\t\t>\n\t\t\t: Else;\n\n\t/**\n\t * Yields `IfSubscriber` when the given type is an acceptable shape for a notification\n\t * listener (subscriber) function. `Else` otherwise.\n\t *\n\t * @system\n\t */\n\texport type IfNotificationSubscriberSignature<Event, IfSubscriber, Else> = Event extends (\n\t\tsender: Attendee,\n\t\t...args: infer P\n\t) => void\n\t\t? InternalCoreInterfacesUtilityTypes.IfSameType<P, JsonSerializable<P>, IfSubscriber, Else>\n\t\t: Else;\n\n\t/**\n\t * Used to specify the kinds of notifications handled by a {@link NotificationListenable}\n\t * by describing the custom parameters in a function signature.\n\t *\n\t * @remarks\n\t *\n\t * Any object type is a valid NotificationListeners, but only the notification-like\n\t * properties of that type will be included.\n\t *\n\t * @example\n\t *\n\t * ```typescript\n\t * interface MyNotifications {\n\t * load: (user: string, data: IUserData) => void;\n\t * requestPause: (period: number) => void;\n\t * }\n\t * ```\n\t *\n\t * @system\n\t */\n\texport type NotificationListeners<E> = {\n\t\t[P in keyof E as IfNotificationParametersSignature<E[P], P, never>]: E[P];\n\t};\n\n\t/**\n\t * Converts a notification subscriber signature into parameters signature\n\t * (by removing the `sender: Attendee` parameter).\n\t *\n\t * @remarks\n\t * No attempt is made to validate that the original signature is valid with\n\t * all parameters being JSON-serializable.\n\t *\n\t * @system\n\t */\n\texport type NotificationParametersSignatureFromSubscriberSignature<Event> = Event extends (\n\t\tsender: Attendee,\n\t\t...args: infer P\n\t) => void\n\t\t? (...args: P) => void\n\t\t: never;\n\n\t/**\n\t * Used to specify the kinds of notifications handled by a {@link NotificationListenable}\n\t * by describing the subscriber signatures.\n\t *\n\t * @remarks\n\t *\n\t * Any object type is a valid NotificationListenersWithSubscriberSignatures,\n\t * but only the notification-like properties of that type will be included.\n\t *\n\t * @example\n\t *\n\t * ```typescript\n\t * interface MyNotifications {\n\t * load: (sender: Attendee, user: string, data: IUserData) => void;\n\t * requestPause: (sender: Attendee, period: number) => void;\n\t * }\n\t * ```\n\t *\n\t * @system\n\t */\n\texport type NotificationListenersWithSubscriberSignatures<E> = {\n\t\t[P in keyof E as IfNotificationSubscriberSignature<E[P], P, never>]: E[P];\n\t};\n\n\t/**\n\t * Converts a record of notification subscriber signatures into\n\t * a record of base parameter signatures (which are the canonical form).\n\t *\n\t * @system\n\t */\n\texport type NotificationListenersFromSubscriberSignatures<\n\t\tE extends NotificationListenersWithSubscriberSignatures<E>,\n\t> = {\n\t\t[K in keyof NotificationListenersWithSubscriberSignatures<E>]: NotificationParametersSignatureFromSubscriberSignature<\n\t\t\tE[K]\n\t\t>;\n\t} extends infer TListeners\n\t\t? // Additional filter is needed to convince TypeScript that the result is NotificationListeners shape\n\t\t\tNotificationListeners<TListeners>\n\t\t: never;\n\n\t/**\n\t * {@link @fluidframework/core-interfaces#JsonDeserialized} version of the parameters of a function.\n\t *\n\t * @system\n\t */\n\texport type JsonDeserializedParameters<T extends (...args: any[]) => unknown> = T extends (\n\t\t...args: infer P\n\t) => unknown\n\t\t? JsonDeserialized<P>\n\t\t: never;\n\n\t/**\n\t * {@link @fluidframework/core-interfaces#JsonSerializable} version of the parameters of a function.\n\t *\n\t * @system\n\t */\n\texport type JsonSerializableParameters<T extends (...args: any[]) => unknown> = T extends (\n\t\t...args: infer P\n\t) => unknown\n\t\t? JsonSerializable<P>\n\t\t: never;\n}\n"]}
|
package/lib/internalUtils.d.ts
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import type { DeepReadonly, InternalCoreInterfacesUtilityTypes, JsonDeserialized, JsonSerializable, OpaqueJsonDeserialized, OpaqueJsonSerializable } from "@fluidframework/core-interfaces/internal";
|
|
6
|
-
import type { ValidatableOptionalState, ValidatableRequiredState } from "./validatableTypes.js";
|
|
7
|
-
/**
|
|
8
|
-
* Returns union of types of values in a record.
|
|
9
|
-
*/
|
|
10
|
-
export type RecordEntryTypes<T> = T[keyof T];
|
|
11
|
-
type MapNumberIndicesToStrings<T> = {
|
|
12
|
-
[K in keyof T as K extends number ? `${K}` : K]: T[K];
|
|
13
|
-
};
|
|
14
|
-
type KeyValuePairs<T> = {
|
|
15
|
-
[K in keyof MapNumberIndicesToStrings<Required<T>>]: [K, Required<T>[K]];
|
|
16
|
-
}[keyof MapNumberIndicesToStrings<Required<T>>][];
|
|
17
|
-
type RequiredAndNotUndefined<T> = {
|
|
18
|
-
[K in keyof T]-?: Exclude<T[K], undefined>;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Object.entries retyped to preserve known keys and their types.
|
|
22
|
-
*
|
|
23
|
-
* @privateRemarks
|
|
24
|
-
* The is a defect in this utility when a string index appears in the object.
|
|
25
|
-
* In such a case, the only result is `[string, T]`, where `T` is the type
|
|
26
|
-
* of the string index entry.
|
|
27
|
-
*/
|
|
28
|
-
export declare const objectEntries: <const T>(o: T) => KeyValuePairs<T>;
|
|
29
|
-
/**
|
|
30
|
-
* Object.entries retyped to preserve known keys and their types.
|
|
31
|
-
*
|
|
32
|
-
* @remarks
|
|
33
|
-
* Given `T` should not contain `undefined` values. If it does, use
|
|
34
|
-
* {@link objectEntries} instead. Without `undefined` values, this
|
|
35
|
-
* typing provides best handling of objects with optional properties.
|
|
36
|
-
*/
|
|
37
|
-
export declare const objectEntriesWithoutUndefined: <const T>(o: T) => KeyValuePairs<RequiredAndNotUndefined<T>>;
|
|
38
|
-
/**
|
|
39
|
-
* Object.keys retyped to preserve known keys and their types.
|
|
40
|
-
*/
|
|
41
|
-
export declare const objectKeys: <const T>(o: T) => (keyof MapNumberIndicesToStrings<T>)[];
|
|
42
|
-
/**
|
|
43
|
-
* Retrieve a value from a record with the given key, or create a new entry if
|
|
44
|
-
* the key is not in the record.
|
|
45
|
-
*
|
|
46
|
-
* @param record - The record to index/update
|
|
47
|
-
* @param key - The key to lookup in the record
|
|
48
|
-
* @param defaultValue - a function which returns a default value. This is
|
|
49
|
-
* called and used to set an initial value for the given key in the record if
|
|
50
|
-
* none exists.
|
|
51
|
-
* @returns either the existing value for the given key, or the newly-created
|
|
52
|
-
* value (the result of `defaultValue`)
|
|
53
|
-
*/
|
|
54
|
-
export declare function getOrCreateRecord<const K extends string | number | symbol, const V>(record: Record<K, V>, key: K, defaultValue: (key: K) => V): V;
|
|
55
|
-
/**
|
|
56
|
-
* No-runtime-effect helper to apply deep immutability to a value's type.
|
|
57
|
-
*/
|
|
58
|
-
export declare function asDeeplyReadonly<T>(value: T): DeepReadonly<T>;
|
|
59
|
-
export declare function asDeeplyReadonlyDeserializedJson<T>(value: OpaqueJsonDeserialized<T>): DeepReadonly<JsonDeserialized<T>>;
|
|
60
|
-
export declare function asDeeplyReadonlyDeserializedJson<T>(value: OpaqueJsonDeserialized<T> | undefined): DeepReadonly<JsonDeserialized<T>> | undefined;
|
|
61
|
-
/**
|
|
62
|
-
* Conditional type that reveals the underlying JSON type of an opaque JSON value. If `T` is an object, the key values
|
|
63
|
-
* will be revealed.
|
|
64
|
-
*/
|
|
65
|
-
type RevealOpaqueJsonDeserialized<T> = T extends OpaqueJsonDeserialized<infer U> ? JsonDeserialized<U> : {
|
|
66
|
-
[Key in keyof T]: RevealOpaqueJsonDeserialized<T[Key]>;
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* No-runtime-effect helper to reveal the JSON type from a value's opaque JSON
|
|
70
|
-
* types throughout a structure.
|
|
71
|
-
*
|
|
72
|
-
* @remarks
|
|
73
|
-
* {@link OpaqueJsonDeserialized} instances will be replaced shallowly such
|
|
74
|
-
* that nested instances are retained.
|
|
75
|
-
*/
|
|
76
|
-
export declare function revealOpaqueJson<T>(value: T): RevealOpaqueJsonDeserialized<T>;
|
|
77
|
-
/**
|
|
78
|
-
* No-runtime-effect helper to automatically cast JSON type to Opaque JSON type
|
|
79
|
-
* at outermost scope.
|
|
80
|
-
*
|
|
81
|
-
* @remarks
|
|
82
|
-
* Types that satisfy {@link JsonSerializable} may also be deserialized. Thus,
|
|
83
|
-
* the return type is both {@link OpaqueJsonSerializable} and
|
|
84
|
-
* {@link OpaqueJsonDeserialized}.
|
|
85
|
-
*/
|
|
86
|
-
export declare function toOpaqueJson<const T>(value: JsonSerializable<T>): OpaqueJsonSerializable<T> & OpaqueJsonDeserialized<T>;
|
|
87
|
-
/**
|
|
88
|
-
* Convert a union of types to an intersection of those types.
|
|
89
|
-
*
|
|
90
|
-
* @privateRemarks
|
|
91
|
-
* First an always true extends clause is used (T extends T) to distribute T
|
|
92
|
-
* into to a union of types contravariant over each member of the T union.
|
|
93
|
-
* Then the constraint on the type parameter in this new context is inferred,
|
|
94
|
-
* giving the intersection.
|
|
95
|
-
*
|
|
96
|
-
* Future: This definition is identical to one in `packages/dds/tree/src/util/typeUtils.ts`
|
|
97
|
-
* and should be consolidated.
|
|
98
|
-
*/
|
|
99
|
-
type UnionToIntersection<T> = (T extends T ? (k: T) => unknown : never) extends (k: infer U) => unknown ? U : never;
|
|
100
|
-
/**
|
|
101
|
-
* Generates a union of types that are the remainder from a simple
|
|
102
|
-
* Pick combination (that is the set of common properties).
|
|
103
|
-
*/
|
|
104
|
-
type PickRemainder<T> = Pick<T, keyof T> extends infer Common ? T extends unknown ? Omit<T, keyof Common> : never : never;
|
|
105
|
-
/**
|
|
106
|
-
* Combines union of structure into a single structure where common properties
|
|
107
|
-
* are unions of their respective types and optional properties are defined for
|
|
108
|
-
* properties that are not common to each union member.
|
|
109
|
-
*
|
|
110
|
-
* @remarks
|
|
111
|
-
* If a property is common to multiple, but not all union member and the
|
|
112
|
-
* types are incompatible, the resulting type will be `never` for that
|
|
113
|
-
* property. (This can be fixed, but might be best addressed by changing
|
|
114
|
-
* T to be a tuple of types to be combined.)
|
|
115
|
-
*/
|
|
116
|
-
export type FlattenUnionWithOptionals<T> = InternalCoreInterfacesUtilityTypes.FlattenIntersection<Pick<T, keyof T> & UnionToIntersection<Partial<PickRemainder<T>>>>;
|
|
117
|
-
/**
|
|
118
|
-
* Type guard to check if a state is a required state (has a value).
|
|
119
|
-
*
|
|
120
|
-
* @param state - The state to check
|
|
121
|
-
* @returns True if the state has a value and is therefore a {@link ValidatableRequiredState}
|
|
122
|
-
*/
|
|
123
|
-
export declare function isValueRequiredState<T>(state: ValidatableRequiredState<T> | ValidatableOptionalState<T>): state is ValidatableRequiredState<T>;
|
|
124
|
-
export {};
|
|
125
|
-
//# sourceMappingURL=internalUtils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"internalUtils.d.ts","sourceRoot":"","sources":["../src/internalUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,YAAY,EACZ,kCAAkC,EAClC,gBAAgB,EAChB,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,0CAA0C,CAAC;AAElD,OAAO,KAAK,EACX,wBAAwB,EACxB,wBAAwB,EACxB,MAAM,uBAAuB,CAAC;AAE/B;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAE7C,KAAK,yBAAyB,CAAC,CAAC,IAAI;KAClC,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,MAAM,GAAG,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACrD,CAAC;AAEF,KAAK,aAAa,CAAC,CAAC,IAAI;KACtB,CAAC,IAAI,MAAM,yBAAyB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACxE,CAAC,MAAM,yBAAyB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAElD,KAAK,uBAAuB,CAAC,CAAC,IAAI;KAChC,CAA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
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Object.entries retyped to preserve known keys and their types.
|
|
7
|
-
*
|
|
8
|
-
* @privateRemarks
|
|
9
|
-
* The is a defect in this utility when a string index appears in the object.
|
|
10
|
-
* In such a case, the only result is `[string, T]`, where `T` is the type
|
|
11
|
-
* of the string index entry.
|
|
12
|
-
*/
|
|
13
|
-
export const objectEntries = Object.entries;
|
|
14
|
-
/**
|
|
15
|
-
* Object.entries retyped to preserve known keys and their types.
|
|
16
|
-
*
|
|
17
|
-
* @remarks
|
|
18
|
-
* Given `T` should not contain `undefined` values. If it does, use
|
|
19
|
-
* {@link objectEntries} instead. Without `undefined` values, this
|
|
20
|
-
* typing provides best handling of objects with optional properties.
|
|
21
|
-
*/
|
|
22
|
-
export const objectEntriesWithoutUndefined = Object.entries;
|
|
23
|
-
/**
|
|
24
|
-
* Object.keys retyped to preserve known keys and their types.
|
|
25
|
-
*/
|
|
26
|
-
export const objectKeys = Object.keys;
|
|
27
|
-
/**
|
|
28
|
-
* Retrieve a value from a record with the given key, or create a new entry if
|
|
29
|
-
* the key is not in the record.
|
|
30
|
-
*
|
|
31
|
-
* @param record - The record to index/update
|
|
32
|
-
* @param key - The key to lookup in the record
|
|
33
|
-
* @param defaultValue - a function which returns a default value. This is
|
|
34
|
-
* called and used to set an initial value for the given key in the record if
|
|
35
|
-
* none exists.
|
|
36
|
-
* @returns either the existing value for the given key, or the newly-created
|
|
37
|
-
* value (the result of `defaultValue`)
|
|
38
|
-
*/
|
|
39
|
-
export function getOrCreateRecord(record, key, defaultValue) {
|
|
40
|
-
if (!(key in record)) {
|
|
41
|
-
record[key] = defaultValue(key);
|
|
42
|
-
}
|
|
43
|
-
return record[key];
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* No-runtime-effect helper to apply deep immutability to a value's type.
|
|
47
|
-
*/
|
|
48
|
-
export function asDeeplyReadonly(value) {
|
|
49
|
-
return value;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* No-runtime-effect helper to apply deep immutability to a value's opaque JSON
|
|
53
|
-
* type, revealing the JSON type.
|
|
54
|
-
*/
|
|
55
|
-
export function asDeeplyReadonlyDeserializedJson(value) {
|
|
56
|
-
return value;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* No-runtime-effect helper to reveal the JSON type from a value's opaque JSON
|
|
60
|
-
* types throughout a structure.
|
|
61
|
-
*
|
|
62
|
-
* @remarks
|
|
63
|
-
* {@link OpaqueJsonDeserialized} instances will be replaced shallowly such
|
|
64
|
-
* that nested instances are retained.
|
|
65
|
-
*/
|
|
66
|
-
export function revealOpaqueJson(value) {
|
|
67
|
-
return value;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* No-runtime-effect helper to automatically cast JSON type to Opaque JSON type
|
|
71
|
-
* at outermost scope.
|
|
72
|
-
*
|
|
73
|
-
* @remarks
|
|
74
|
-
* Types that satisfy {@link JsonSerializable} may also be deserialized. Thus,
|
|
75
|
-
* the return type is both {@link OpaqueJsonSerializable} and
|
|
76
|
-
* {@link OpaqueJsonDeserialized}.
|
|
77
|
-
*/
|
|
78
|
-
export function toOpaqueJson(value) {
|
|
79
|
-
return value;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Type guard to check if a state is a required state (has a value).
|
|
83
|
-
*
|
|
84
|
-
* @param state - The state to check
|
|
85
|
-
* @returns True if the state has a value and is therefore a {@link ValidatableRequiredState}
|
|
86
|
-
*/
|
|
87
|
-
export function isValueRequiredState(state) {
|
|
88
|
-
return state.value !== undefined;
|
|
89
|
-
}
|
|
90
|
-
//# sourceMappingURL=internalUtils.js.map
|
package/lib/internalUtils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"internalUtils.js","sourceRoot":"","sources":["../src/internalUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAiCH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,OAA8C,CAAC;AAEnF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,MAAM,CAAC,OAEN,CAAC;AAE/C;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,IAEU,CAAC;AAE5C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,iBAAiB,CAChC,MAAoB,EACpB,GAAM,EACN,YAA2B;IAE3B,IAAI,CAAC,CAAC,GAAG,IAAI,MAAM,CAAC,EAAE,CAAC;QACtB,MAAM,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;AACpB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAI,KAAQ;IAC3C,OAAO,KAAwB,CAAC;AACjC,CAAC;AASD;;;GAGG;AACH,MAAM,UAAU,gCAAgC,CAC/C,KAA4C;IAE5C,OAAO,KAAsD,CAAC;AAC/D,CAAC;AAWD;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAI,KAAQ;IAC3C,OAAO,KAAwC,CAAC;AACjD,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAC3B,KAA0B;IAE1B,OAAO,KAA8D,CAAC;AACvE,CAAC;AA+CD;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CACnC,KAAgE;IAEhE,OAAO,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC;AAClC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tDeepReadonly,\n\tInternalCoreInterfacesUtilityTypes,\n\tJsonDeserialized,\n\tJsonSerializable,\n\tOpaqueJsonDeserialized,\n\tOpaqueJsonSerializable,\n} from \"@fluidframework/core-interfaces/internal\";\n\nimport type {\n\tValidatableOptionalState,\n\tValidatableRequiredState,\n} from \"./validatableTypes.js\";\n\n/**\n * Returns union of types of values in a record.\n */\nexport type RecordEntryTypes<T> = T[keyof T];\n\ntype MapNumberIndicesToStrings<T> = {\n\t[K in keyof T as K extends number ? `${K}` : K]: T[K];\n};\n\ntype KeyValuePairs<T> = {\n\t[K in keyof MapNumberIndicesToStrings<Required<T>>]: [K, Required<T>[K]];\n}[keyof MapNumberIndicesToStrings<Required<T>>][];\n\ntype RequiredAndNotUndefined<T> = {\n\t[K in keyof T]-?: Exclude<T[K], undefined>;\n};\n\n/**\n * Object.entries retyped to preserve known keys and their types.\n *\n * @privateRemarks\n * The is a defect in this utility when a string index appears in the object.\n * In such a case, the only result is `[string, T]`, where `T` is the type\n * of the string index entry.\n */\nexport const objectEntries = Object.entries as <const T>(o: T) => KeyValuePairs<T>;\n\n/**\n * Object.entries retyped to preserve known keys and their types.\n *\n * @remarks\n * Given `T` should not contain `undefined` values. If it does, use\n * {@link objectEntries} instead. Without `undefined` values, this\n * typing provides best handling of objects with optional properties.\n */\nexport const objectEntriesWithoutUndefined = Object.entries as <const T>(\n\to: T,\n) => KeyValuePairs<RequiredAndNotUndefined<T>>;\n\n/**\n * Object.keys retyped to preserve known keys and their types.\n */\nexport const objectKeys = Object.keys as <const T>(\n\to: T,\n) => (keyof MapNumberIndicesToStrings<T>)[];\n\n/**\n * Retrieve a value from a record with the given key, or create a new entry if\n * the key is not in the record.\n *\n * @param record - The record to index/update\n * @param key - The key to lookup in the record\n * @param defaultValue - a function which returns a default value. This is\n * called and used to set an initial value for the given key in the record if\n * none exists.\n * @returns either the existing value for the given key, or the newly-created\n * value (the result of `defaultValue`)\n */\nexport function getOrCreateRecord<const K extends string | number | symbol, const V>(\n\trecord: Record<K, V>,\n\tkey: K,\n\tdefaultValue: (key: K) => V,\n): V {\n\tif (!(key in record)) {\n\t\trecord[key] = defaultValue(key);\n\t}\n\treturn record[key];\n}\n\n/**\n * No-runtime-effect helper to apply deep immutability to a value's type.\n */\nexport function asDeeplyReadonly<T>(value: T): DeepReadonly<T> {\n\treturn value as DeepReadonly<T>;\n}\n\n// function overloads\nexport function asDeeplyReadonlyDeserializedJson<T>(\n\tvalue: OpaqueJsonDeserialized<T>,\n): DeepReadonly<JsonDeserialized<T>>;\nexport function asDeeplyReadonlyDeserializedJson<T>(\n\tvalue: OpaqueJsonDeserialized<T> | undefined,\n): DeepReadonly<JsonDeserialized<T>> | undefined;\n/**\n * No-runtime-effect helper to apply deep immutability to a value's opaque JSON\n * type, revealing the JSON type.\n */\nexport function asDeeplyReadonlyDeserializedJson<T>(\n\tvalue: OpaqueJsonDeserialized<T> | undefined,\n): DeepReadonly<JsonDeserialized<T>> | undefined {\n\treturn value as DeepReadonly<JsonDeserialized<T>> | undefined;\n}\n\n/**\n * Conditional type that reveals the underlying JSON type of an opaque JSON value. If `T` is an object, the key values\n * will be revealed.\n */\ntype RevealOpaqueJsonDeserialized<T> =\n\tT extends OpaqueJsonDeserialized<infer U>\n\t\t? JsonDeserialized<U>\n\t\t: { [Key in keyof T]: RevealOpaqueJsonDeserialized<T[Key]> };\n\n/**\n * No-runtime-effect helper to reveal the JSON type from a value's opaque JSON\n * types throughout a structure.\n *\n * @remarks\n * {@link OpaqueJsonDeserialized} instances will be replaced shallowly such\n * that nested instances are retained.\n */\nexport function revealOpaqueJson<T>(value: T): RevealOpaqueJsonDeserialized<T> {\n\treturn value as RevealOpaqueJsonDeserialized<T>;\n}\n\n/**\n * No-runtime-effect helper to automatically cast JSON type to Opaque JSON type\n * at outermost scope.\n *\n * @remarks\n * Types that satisfy {@link JsonSerializable} may also be deserialized. Thus,\n * the return type is both {@link OpaqueJsonSerializable} and\n * {@link OpaqueJsonDeserialized}.\n */\nexport function toOpaqueJson<const T>(\n\tvalue: JsonSerializable<T>,\n): OpaqueJsonSerializable<T> & OpaqueJsonDeserialized<T> {\n\treturn value as OpaqueJsonSerializable<T> & OpaqueJsonDeserialized<T>;\n}\n\n/**\n * Convert a union of types to an intersection of those types.\n *\n * @privateRemarks\n * First an always true extends clause is used (T extends T) to distribute T\n * into to a union of types contravariant over each member of the T union.\n * Then the constraint on the type parameter in this new context is inferred,\n * giving the intersection.\n *\n * Future: This definition is identical to one in `packages/dds/tree/src/util/typeUtils.ts`\n * and should be consolidated.\n */\ntype UnionToIntersection<T> = (T extends T ? (k: T) => unknown : never) extends (\n\tk: infer U,\n) => unknown\n\t? U\n\t: never;\n\n/**\n * Generates a union of types that are the remainder from a simple\n * Pick combination (that is the set of common properties).\n */\ntype PickRemainder<T> =\n\tPick<T, keyof T> extends infer Common\n\t\t? T extends unknown\n\t\t\t? Omit<T, keyof Common>\n\t\t\t: never\n\t\t: never;\n\n/**\n * Combines union of structure into a single structure where common properties\n * are unions of their respective types and optional properties are defined for\n * properties that are not common to each union member.\n *\n * @remarks\n * If a property is common to multiple, but not all union member and the\n * types are incompatible, the resulting type will be `never` for that\n * property. (This can be fixed, but might be best addressed by changing\n * T to be a tuple of types to be combined.)\n */\nexport type FlattenUnionWithOptionals<T> =\n\tInternalCoreInterfacesUtilityTypes.FlattenIntersection<\n\t\tPick<T, keyof T> & UnionToIntersection<Partial<PickRemainder<T>>>\n\t>;\n\n/**\n * Type guard to check if a state is a required state (has a value).\n *\n * @param state - The state to check\n * @returns True if the state has a value and is therefore a {@link ValidatableRequiredState}\n */\nexport function isValueRequiredState<T>(\n\tstate: ValidatableRequiredState<T> | ValidatableOptionalState<T>,\n): state is ValidatableRequiredState<T> {\n\treturn state.value !== undefined;\n}\n"]}
|