@fluidframework/core-interfaces 2.70.0-360374 → 2.70.0-361092

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAC7F,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,YAAY,EACX,mBAAmB,EACnB,WAAW,EACX,MAAM,EACN,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,4BAA4B,EAC5B,gBAAgB,GAChB,MAAM,aAAa,CAAC;AAErB,YAAY,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AACvF,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAKpE,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE5E,YAAY,EACX,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,kCAAkC,EAClC,0BAA0B,EAC1B,iBAAiB,EACjB,uBAAuB,EACvB,mBAAmB,EACnB,0BAA0B,EAC1B,YAAY,GACZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEpF,YAAY,EACX,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,MAAM,EACN,8BAA8B,GAC9B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACv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mBAAmB,EACnB,0BAA0B,EAC1B,YAAY,GACZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEpF,YAAY,EACX,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,MAAM,EACN,8BAA8B,GAC9B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,YAAY,EAAE,uBAAuB,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC3F,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACpE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACnE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,YAAY,EACX,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,SAAS,EACT,UAAU,EACV,SAAS,EACT,mBAAmB,EACnB,GAAG,GACH,MAAM,mBAAmB,CAAC"}
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAc7C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAmBpE,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAUpF,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAKvC,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport type { BrandedType } from \"./brandedType.js\";\n\nexport type { IDisposable } from \"./disposable.js\";\n\nexport type { IErrorBase, IGenericError, IUsageError, IThrottlingWarning } from \"./error.js\";\nexport { FluidErrorTypes } from \"./error.js\";\n\nexport type {\n\tExtendEventProvider,\n\tIErrorEvent,\n\tIEvent,\n\tIEventProvider,\n\tIEventThisPlaceHolder,\n\tIEventTransformer,\n\tReplaceIEventThisPlaceHolder,\n\tTransformedEvent,\n} from \"./events.js\";\n\nexport type { IProvideFluidLoadable, IProvideFluidRunnable } from \"./fluidLoadable.js\";\nexport { IFluidLoadable, IFluidRunnable } from \"./fluidLoadable.js\";\n\n// TypeScript forgets the index signature when customers augment IRequestHeader if we export *.\n// So we export the explicit members as a workaround:\n// https://github.com/microsoft/TypeScript/issues/18877#issuecomment-476921038\nexport type { IRequest, IRequestHeader, IResponse } from \"./fluidRouter.js\";\n\nexport type {\n\tIFluidHandleErased,\n\tIFluidHandleEvents,\n\tIFluidHandleInternal,\n\tIFluidHandleInternalPayloadPending,\n\tIFluidHandlePayloadPending,\n\tILocalFluidHandle,\n\tILocalFluidHandleEvents,\n\tIProvideFluidHandle,\n\tIProvideFluidHandleContext,\n\tPayloadState,\n} from \"./handles.js\";\nexport { IFluidHandleContext, IFluidHandle, fluidHandleSymbol } from \"./handles.js\";\n\nexport type {\n\tILoggingError,\n\tITelemetryBaseEvent,\n\tITelemetryBaseLogger,\n\tITelemetryBaseProperties,\n\tTagged,\n\tTelemetryBaseEventPropertyType,\n} from \"./logger.js\";\nexport { LogLevel } from \"./logger.js\";\nexport type { FluidObjectProviderKeys, FluidObject, FluidObjectKeys } from \"./provider.js\";\nexport type { ConfigTypes, IConfigProviderBase } from \"./config.js\";\nexport type { ISignalEnvelope, TypedMessage } from \"./messages.js\";\nexport type { ErasedType, ErasedBaseType } from \"./erasedType.js\";\nexport { ErasedTypeImplementation } from \"./erasedType.js\";\n\nexport type {\n\tHasListeners,\n\tIEmitter,\n\tIsListener,\n\tListeners,\n\tListenable,\n\tMapGetSet,\n\tNoListenersCallback,\n\tOff,\n} from \"./events/index.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAc7C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAmBpE,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAUpF,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAKvC,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport type { BrandedType } from \"./brandedType.js\";\n\nexport type { IDisposable } from \"./disposable.js\";\n\nexport type { IErrorBase, IGenericError, IUsageError, IThrottlingWarning } from \"./error.js\";\nexport { FluidErrorTypes } from \"./error.js\";\n\nexport type {\n\tExtendEventProvider,\n\tIErrorEvent,\n\tIEvent,\n\tIEventProvider,\n\tIEventThisPlaceHolder,\n\tIEventTransformer,\n\tReplaceIEventThisPlaceHolder,\n\tTransformedEvent,\n} from \"./events.js\";\n\nexport type { IProvideFluidLoadable, IProvideFluidRunnable } from \"./fluidLoadable.js\";\nexport { IFluidLoadable, IFluidRunnable } from \"./fluidLoadable.js\";\n\n// TypeScript forgets the index signature when customers augment IRequestHeader if we export *.\n// So we export the explicit members as a workaround:\n// https://github.com/microsoft/TypeScript/issues/18877#issuecomment-476921038\nexport type { IRequest, IRequestHeader, IResponse } from \"./fluidRouter.js\";\n\nexport type {\n\tIFluidHandleErased,\n\tIFluidHandleEvents,\n\tIFluidHandleInternal,\n\tIFluidHandleInternalPayloadPending,\n\tIFluidHandlePayloadPending,\n\tILocalFluidHandle,\n\tILocalFluidHandleEvents,\n\tIProvideFluidHandle,\n\tIProvideFluidHandleContext,\n\tPayloadState,\n} from \"./handles.js\";\nexport { IFluidHandleContext, IFluidHandle, fluidHandleSymbol } from \"./handles.js\";\n\nexport type {\n\tILoggingError,\n\tITelemetryBaseEvent,\n\tITelemetryBaseLogger,\n\tITelemetryBaseProperties,\n\tTagged,\n\tTelemetryBaseEventPropertyType,\n} from \"./logger.js\";\nexport { LogLevel } from \"./logger.js\";\nexport type { FluidObjectProviderKeys, FluidObject, FluidObjectKeys } from \"./provider.js\";\nexport type { ConfigTypes, IConfigProviderBase } from \"./config.js\";\nexport type { ISignalEnvelope, TypedMessage } from \"./messages.js\";\nexport type { ErasedType, ErasedBaseType, InstanceTypeRelaxed } from \"./erasedType.js\";\nexport { ErasedTypeImplementation } from \"./erasedType.js\";\n\nexport type {\n\tHasListeners,\n\tIEmitter,\n\tIsListener,\n\tListeners,\n\tListenable,\n\tMapGetSet,\n\tNoListenersCallback,\n\tOff,\n} from \"./events/index.js\";\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/core-interfaces",
3
- "version": "2.70.0-360374",
3
+ "version": "2.70.0-361092",
4
4
  "description": "Fluid object interfaces",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -76,8 +76,8 @@
76
76
  "@fluid-tools/build-cli": "^0.58.3",
77
77
  "@fluidframework/build-common": "^2.0.3",
78
78
  "@fluidframework/build-tools": "^0.58.3",
79
- "@fluidframework/core-interfaces-previous": "npm:@fluidframework/core-interfaces@2.62.0",
80
- "@fluidframework/eslint-config-fluid": "^6.0.0",
79
+ "@fluidframework/core-interfaces-previous": "npm:@fluidframework/core-interfaces@2.63.0",
80
+ "@fluidframework/eslint-config-fluid": "^6.1.0",
81
81
  "@microsoft/api-extractor": "7.52.11",
82
82
  "@types/mocha": "^10.0.10",
83
83
  "@types/node": "^18.19.0",
@@ -85,7 +85,7 @@
85
85
  "concurrently": "^8.2.1",
86
86
  "copyfiles": "^2.4.1",
87
87
  "cross-env": "^7.0.3",
88
- "eslint": "~8.55.0",
88
+ "eslint": "~8.57.1",
89
89
  "mocha": "^10.8.2",
90
90
  "mocha-multi-reporters": "^1.5.1",
91
91
  "rimraf": "^4.4.0",
package/src/erasedType.ts CHANGED
@@ -144,24 +144,34 @@ export abstract class ErasedTypeImplementation<
144
144
  }
145
145
 
146
146
  /**
147
- * Allows narrowing from TInterface to the internal implementation type via `instanceof`.
147
+ * {@link https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates|Type predicate} for narrowing the internal implementation type via `instanceof`.
148
148
  */
149
- public static [Symbol.hasInstance]<
150
- TThis extends abstract new (
151
- ...args: unknown[]
152
- ) => object,
153
- >(this: TThis, value: ErasedBaseType | InstanceType<TThis>): value is InstanceType<TThis> {
154
- return Object.prototype.isPrototypeOf.call(this.prototype, value);
149
+ public static [Symbol.hasInstance]<TThis extends { prototype: object }>(
150
+ this: TThis,
151
+ value: unknown,
152
+ ): value is InstanceTypeRelaxed<TThis> {
153
+ return (
154
+ typeof value === "object" &&
155
+ value !== null &&
156
+ Object.prototype.isPrototypeOf.call(this.prototype, value)
157
+ );
155
158
  }
156
159
 
157
160
  /**
158
- * Narrows from TInterface to the internal implementation type, throwing if the value is not of the correct type.
161
+ * {@link https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions|Type assertion} which narrows from ErasedBaseType to the internal implementation type.
162
+ * @remarks
163
+ * This does a checked conversion, throwing a `TypeError` if invalid.
164
+ *
165
+ * It would be safer if this narrowed from `TInterface`, but that is not possible since type parameters can not be accessed in static methods.
166
+ * Replacing `ErasedTypeImplementation` with a generic function which returns a non-generic class could be used to work around this limitation if desired.
167
+ *
168
+ * Derived classes can provide their own customized narrowing function with a more specific types if desired.
159
169
  */
160
- public static narrow<TThis extends abstract new (...args: unknown[]) => object>(
170
+ public static narrow<TThis extends { prototype: object }>(
161
171
  this: TThis,
162
- value: ErasedBaseType | InstanceType<TThis>,
163
- ): asserts value is InstanceType<TThis> {
164
- if (!Object.prototype.isPrototypeOf.call(this.prototype, value)) {
172
+ value: ErasedBaseType | InstanceTypeRelaxed<TThis>,
173
+ ): asserts value is InstanceTypeRelaxed<TThis> {
174
+ if (!ErasedTypeImplementation[Symbol.hasInstance].call(this, value as object)) {
165
175
  throw new TypeError("Invalid ErasedBaseType instance");
166
176
  }
167
177
  }
@@ -169,9 +179,17 @@ export abstract class ErasedTypeImplementation<
169
179
  /**
170
180
  * Upcasts the instance to the erased interface type.
171
181
  * @remarks
172
- * This is mainly useful when inferring interface type is required.
182
+ * This is mainly useful when inferring the interface type is required.
173
183
  */
174
184
  public upCast<TThis extends TInterface>(this: TThis): TInterface {
175
185
  return this;
176
186
  }
177
187
  }
188
+
189
+ /**
190
+ * The same as the built-in InstanceType, but works on classes with private constructors.
191
+ * @privateRemarks
192
+ * This is based on the trick in {@link https://stackoverflow.com/a/74657881}.
193
+ * @internal
194
+ */
195
+ export type InstanceTypeRelaxed<TClass> = InstanceType<(new () => never) & TClass>;
@@ -212,7 +212,7 @@ export namespace InternalUtilityTypes {
212
212
  | symbol
213
213
  | undefined
214
214
  ? /* not serializable => */ Result["WhenNeverDeserializable"]
215
- : // eslint-disable-next-line @typescript-eslint/ban-types
215
+ : // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type, @typescript-eslint/ban-types
216
216
  T extends Function
217
217
  ? ExtractFunctionFromIntersection<T> extends {
218
218
  classification: "exactly Function";
@@ -307,7 +307,7 @@ export namespace InternalUtilityTypes {
307
307
  /* extract types that might lead to missing property */ Extract<
308
308
  PossibleTypeLessAllowed,
309
309
  /* types that might lead to missing property, except `bigint` */
310
- // eslint-disable-next-line @typescript-eslint/ban-types
310
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type, @typescript-eslint/ban-types
311
311
  undefined | symbol | Function
312
312
  > extends never
313
313
  ? /* all types are supported plus possibly `bigint` => */
@@ -371,7 +371,7 @@ export namespace InternalUtilityTypes {
371
371
  ? Extract<
372
372
  IfSameType<PossibleTypeLessAllowed, unknown, undefined, PossibleTypeLessAllowed>,
373
373
  /* types that might lead to missing property */
374
- // eslint-disable-next-line @typescript-eslint/ban-types
374
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type, @typescript-eslint/ban-types
375
375
  undefined | symbol | Function
376
376
  > extends never
377
377
  ? /* exclusively supported types or exactly `never` */ never
@@ -463,7 +463,7 @@ export namespace InternalUtilityTypes {
463
463
  /* exactly replaced => */ T,
464
464
  /* test for known types that become null */ T extends undefined | symbol
465
465
  ? /* => */ null
466
- : // eslint-disable-next-line @typescript-eslint/ban-types
466
+ : // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type, @typescript-eslint/ban-types
467
467
  T extends Function
468
468
  ? ExtractFunctionFromIntersection<T> extends {
469
469
  classification: "exactly Function";
@@ -484,7 +484,7 @@ export namespace InternalUtilityTypes {
484
484
  NotEnumLike = unknown,
485
485
  > = T extends readonly (infer _)[]
486
486
  ? /* array => */ NotEnumLike
487
- : // eslint-disable-next-line @typescript-eslint/ban-types
487
+ : // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type, @typescript-eslint/ban-types
488
488
  T extends Function
489
489
  ? /* function => */ NotEnumLike
490
490
  : T extends {
@@ -1050,7 +1050,7 @@ export namespace InternalUtilityTypes {
1050
1050
  "no match"
1051
1051
  > extends true
1052
1052
  ? /* exact alternate type => */ T
1053
- : // eslint-disable-next-line @typescript-eslint/ban-types
1053
+ : // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type, @typescript-eslint/ban-types
1054
1054
  /* test for not a function */ Extract<T, Function> extends never
1055
1055
  ? /* not a function => test for object */ T extends object
1056
1056
  ? /* object => test for array */ T extends readonly (infer _)[]
package/src/handles.ts CHANGED
@@ -223,5 +223,5 @@ export interface IFluidHandle<out T = unknown> {
223
223
  * Created from {@link IFluidHandleInternal} using {@link toFluidHandleErased}.
224
224
  * @sealed @public
225
225
  */
226
- // eslint-disable-next-line @typescript-eslint/no-empty-interface
226
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type, @typescript-eslint/no-empty-interface
227
227
  export interface IFluidHandleErased<T> extends ErasedType<readonly ["IFluidHandle", T]> {}
package/src/index.ts CHANGED
@@ -55,7 +55,7 @@ export { LogLevel } from "./logger.js";
55
55
  export type { FluidObjectProviderKeys, FluidObject, FluidObjectKeys } from "./provider.js";
56
56
  export type { ConfigTypes, IConfigProviderBase } from "./config.js";
57
57
  export type { ISignalEnvelope, TypedMessage } from "./messages.js";
58
- export type { ErasedType, ErasedBaseType } from "./erasedType.js";
58
+ export type { ErasedType, ErasedBaseType, InstanceTypeRelaxed } from "./erasedType.js";
59
59
  export { ErasedTypeImplementation } from "./erasedType.js";
60
60
 
61
61
  export type {