@fluidframework/core-interfaces 2.91.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.
Files changed (96) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +1 -1
  3. package/api-report/core-interfaces.beta.api.md +7 -0
  4. package/api-report/core-interfaces.legacy.alpha.api.md +37 -1
  5. package/api-report/core-interfaces.legacy.beta.api.md +37 -1
  6. package/api-report/core-interfaces.legacy.public.api.md +7 -0
  7. package/api-report/core-interfaces.public.api.md +7 -0
  8. package/dist/brandedType.d.ts +14 -1
  9. package/dist/brandedType.d.ts.map +1 -1
  10. package/dist/brandedType.js.map +1 -1
  11. package/dist/deepReadonly.d.ts +3 -3
  12. package/dist/deepReadonly.js.map +1 -1
  13. package/dist/erasedType.d.ts +28 -3
  14. package/dist/erasedType.d.ts.map +1 -1
  15. package/dist/erasedType.js +7 -70
  16. package/dist/erasedType.js.map +1 -1
  17. package/dist/exposedInternalUtilityTypes.d.ts +3 -3
  18. package/dist/exposedInternalUtilityTypes.js.map +1 -1
  19. package/dist/fluidLoadable.d.ts +0 -17
  20. package/dist/fluidLoadable.d.ts.map +1 -1
  21. package/dist/fluidLoadable.js +1 -5
  22. package/dist/fluidLoadable.js.map +1 -1
  23. package/dist/fluidMap.d.ts +133 -0
  24. package/dist/fluidMap.d.ts.map +1 -0
  25. package/dist/fluidMap.js +7 -0
  26. package/dist/fluidMap.js.map +1 -0
  27. package/dist/index.d.ts +3 -2
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +1 -2
  30. package/dist/index.js.map +1 -1
  31. package/dist/jsonDeserialized.d.ts +2 -2
  32. package/dist/jsonDeserialized.js.map +1 -1
  33. package/dist/jsonSerializable.d.ts +2 -2
  34. package/dist/jsonSerializable.js.map +1 -1
  35. package/dist/jsonSerializationErrors.d.ts +2 -2
  36. package/dist/jsonSerializationErrors.js.map +1 -1
  37. package/dist/jsonType.d.ts +3 -3
  38. package/dist/jsonType.js.map +1 -1
  39. package/dist/legacy.alpha.d.ts +7 -3
  40. package/dist/legacy.d.ts +7 -3
  41. package/dist/opaqueJson.d.ts +2 -2
  42. package/dist/opaqueJson.js.map +1 -1
  43. package/dist/public.d.ts +2 -1
  44. package/eslint.config.mts +1 -1
  45. package/legacy/alpha.d.ts +1 -1
  46. package/legacy.d.ts +1 -1
  47. package/lib/brandedType.d.ts +14 -1
  48. package/lib/brandedType.d.ts.map +1 -1
  49. package/lib/brandedType.js.map +1 -1
  50. package/lib/deepReadonly.d.ts +3 -3
  51. package/lib/deepReadonly.js.map +1 -1
  52. package/lib/erasedType.d.ts +28 -3
  53. package/lib/erasedType.d.ts.map +1 -1
  54. package/lib/erasedType.js +6 -68
  55. package/lib/erasedType.js.map +1 -1
  56. package/lib/exposedInternalUtilityTypes.d.ts +3 -3
  57. package/lib/exposedInternalUtilityTypes.js.map +1 -1
  58. package/lib/fluidLoadable.d.ts +0 -17
  59. package/lib/fluidLoadable.d.ts.map +1 -1
  60. package/lib/fluidLoadable.js +0 -4
  61. package/lib/fluidLoadable.js.map +1 -1
  62. package/lib/fluidMap.d.ts +133 -0
  63. package/lib/fluidMap.d.ts.map +1 -0
  64. package/lib/fluidMap.js +6 -0
  65. package/lib/fluidMap.js.map +1 -0
  66. package/lib/index.d.ts +3 -2
  67. package/lib/index.d.ts.map +1 -1
  68. package/lib/index.js +1 -1
  69. package/lib/index.js.map +1 -1
  70. package/lib/jsonDeserialized.d.ts +2 -2
  71. package/lib/jsonDeserialized.js.map +1 -1
  72. package/lib/jsonSerializable.d.ts +2 -2
  73. package/lib/jsonSerializable.js.map +1 -1
  74. package/lib/jsonSerializationErrors.d.ts +2 -2
  75. package/lib/jsonSerializationErrors.js.map +1 -1
  76. package/lib/jsonType.d.ts +3 -3
  77. package/lib/jsonType.js.map +1 -1
  78. package/lib/legacy.alpha.d.ts +7 -3
  79. package/lib/legacy.d.ts +7 -3
  80. package/lib/opaqueJson.d.ts +2 -2
  81. package/lib/opaqueJson.js.map +1 -1
  82. package/lib/public.d.ts +2 -1
  83. package/lib/tsdoc-metadata.json +1 -1
  84. package/package.json +9 -10
  85. package/src/brandedType.ts +14 -1
  86. package/src/deepReadonly.ts +3 -3
  87. package/src/erasedType.ts +31 -10
  88. package/src/exposedInternalUtilityTypes.ts +3 -3
  89. package/src/fluidLoadable.ts +0 -21
  90. package/src/fluidMap.ts +151 -0
  91. package/src/index.ts +9 -2
  92. package/src/jsonDeserialized.ts +2 -2
  93. package/src/jsonSerializable.ts +2 -2
  94. package/src/jsonSerializationErrors.ts +2 -2
  95. package/src/jsonType.ts +3 -3
  96. package/src/opaqueJson.ts +2 -2
@@ -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,EACX,UAAU,EACV,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,0BAA0B,GAC1B,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,eAAe,EACf,oBAAoB,GACpB,MAAM,YAAY,CAAC;AAEpB,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,uB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MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.ErasedTypeImplementation = exports.LogLevel = exports.fluidHandleSymbol = exports.IFluidHandle = exports.IFluidHandleContext = exports.IFluidRunnable = exports.IFluidLoadable = exports.FluidErrorTypesAlpha = exports.FluidErrorTypes = void 0;
7
+ exports.ErasedTypeImplementation = exports.LogLevel = exports.fluidHandleSymbol = exports.IFluidHandle = exports.IFluidHandleContext = exports.IFluidLoadable = exports.FluidErrorTypesAlpha = exports.FluidErrorTypes = void 0;
8
8
  var error_js_1 = require("./error.js");
9
9
  Object.defineProperty(exports, "FluidErrorTypes", { enumerable: true, get: function () { return error_js_1.FluidErrorTypes; } });
10
10
  Object.defineProperty(exports, "FluidErrorTypesAlpha", { enumerable: true, get: function () { return error_js_1.FluidErrorTypesAlpha; } });
11
11
  var fluidLoadable_js_1 = require("./fluidLoadable.js");
12
12
  Object.defineProperty(exports, "IFluidLoadable", { enumerable: true, get: function () { return fluidLoadable_js_1.IFluidLoadable; } });
13
- Object.defineProperty(exports, "IFluidRunnable", { enumerable: true, get: function () { return fluidLoadable_js_1.IFluidRunnable; } });
14
13
  var handles_js_1 = require("./handles.js");
15
14
  Object.defineProperty(exports, "IFluidHandleContext", { enumerable: true, get: function () { return handles_js_1.IFluidHandleContext; } });
16
15
  Object.defineProperty(exports, "IFluidHandle", { enumerable: true, get: function () { return handles_js_1.IFluidHandle; } });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAaH,uCAGoB;AAFnB,2GAAA,eAAe,OAAA;AACf,gHAAA,oBAAoB,OAAA;AAerB,uDAAoE;AAA3D,kHAAA,cAAc,OAAA;AAAE,kHAAA,cAAc,OAAA;AAmBvC,2CAAoF;AAA3E,iHAAA,mBAAmB,OAAA;AAAE,0GAAA,YAAY,OAAA;AAAE,+GAAA,iBAAiB,OAAA;AAU7D,yCAAuC;AAA9B,qGAAA,QAAQ,OAAA;AAKjB,iDAA2D;AAAlD,yHAAA,wBAAwB,OAAA","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 {\n\tIErrorBase,\n\tIGenericError,\n\tIUsageError,\n\tIThrottlingWarning,\n\tILayerIncompatibilityError,\n} from \"./error.js\";\nexport {\n\tFluidErrorTypes,\n\tFluidErrorTypesAlpha,\n} 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"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAoBH,uCAGoB;AAFnB,2GAAA,eAAe,OAAA;AACf,gHAAA,oBAAoB,OAAA;AAerB,uDAAoD;AAA3C,kHAAA,cAAc,OAAA;AAmBvB,2CAAoF;AAA3E,iHAAA,mBAAmB,OAAA;AAAE,0GAAA,YAAY,OAAA;AAAE,+GAAA,iBAAiB,OAAA;AAU7D,yCAAuC;AAA9B,qGAAA,QAAQ,OAAA;AAKjB,iDAA2D;AAAlD,yHAAA,wBAAwB,OAAA","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 {\n\tFluidIterable,\n\tFluidIterableIterator,\n\tFluidMap,\n\tFluidReadonlyMap,\n} from \"./fluidMap.js\";\n\nexport type {\n\tIErrorBase,\n\tIGenericError,\n\tIUsageError,\n\tIThrottlingWarning,\n\tILayerIncompatibilityError,\n} from \"./error.js\";\nexport {\n\tFluidErrorTypes,\n\tFluidErrorTypesAlpha,\n} 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 } from \"./fluidLoadable.js\";\nexport { IFluidLoadable } 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"]}
@@ -6,7 +6,7 @@ import type { InternalUtilityTypes } from "./exposedInternalUtilityTypes.js";
6
6
  /**
7
7
  * Options for {@link JsonDeserialized}.
8
8
  *
9
- * @beta
9
+ * @public
10
10
  */
11
11
  export interface JsonDeserializedOptions {
12
12
  /**
@@ -103,7 +103,7 @@ export interface JsonDeserializedOptions {
103
103
  * function foo<T>(): JsonDeserialized<T> { ... }
104
104
  * ```
105
105
  *
106
- * @beta
106
+ * @public
107
107
  */
108
108
  export type JsonDeserialized<T, Options extends JsonDeserializedOptions = {
109
109
  AllowExactly: [];
@@ -1 +1 @@
1
- {"version":3,"file":"jsonDeserialized.js","sourceRoot":"","sources":["../src/jsonDeserialized.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 { InternalUtilityTypes } from \"./exposedInternalUtilityTypes.js\";\n\n/**\n * Options for {@link JsonDeserialized}.\n *\n * @beta\n */\nexport interface JsonDeserializedOptions {\n\t/**\n\t * Tuple of exact types that are managed by custom deserialization logic (beyond\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse|JSON.parse}\n\t * without a reviver). Only exact types matching specification will be\n\t * preserved unaltered.\n\t *\n\t * The default value is `[]`.\n\t */\n\tAllowExactly?: unknown[];\n\n\t/**\n\t * General types that are managed by custom deserialization logic (beyond\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse|JSON.parse}\n\t * without a reviver). Any type satisfying specification will be preserved\n\t * unaltered.\n\t *\n\t * The default value is `never`.\n\t */\n\tAllowExtensionOf?: unknown;\n}\n\n/**\n * Produces a type that results from a type `T` serialized and deserialized\n * through JSON using {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify|JSON.stringify}\n * (without replacer) and {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse|JSON.parse}\n * (without reviver), respectively as base model.\n *\n * @typeParam T - The type that was serialized.\n * @typeParam Options - Options for the filter. See {@link JsonDeserializedOptions}.\n *\n * @remarks\n * Before adding use of this utility type, consider using a utility like\n * {@link https://github.com/sinclairzx81/typebox#readme | TypeBox} that allows\n * for runtime validation.\n *\n * This filter can be used to derive the expected type of a JSON deserialized\n * value whether or not the type of value serialized meets serialization\n * constraints (see {@link JsonSerializable} including serialization pitfalls).\n *\n * When used as a filter to inferred generic `T`, a compile-time error can be\n * produced trying to assign `JsonDeserialized<T>` to `T`.\n *\n * Simply deserialized JSON never contains `bigint`, `undefined`, `symbol`,\n * or function values. (Object properties which had those types before encoding\n * are omitted during serialization and thus won't be present after\n * deserialization.) Therefore, through this filter, such properties:\n *\n * - become optional with those types excluded (when there are other supported\n * types in union)\n *\n * - are removed (when nothing else in union is supported)\n *\n * - in an array are (1) replaced with `null` if `undefined`, `symbol`, and\n * function values or (2) simply removed (become `never`) if `bigint` value as\n * serialization attempts will throw.\n *\n * Examples results:\n *\n * | Before serialization | After deserialization | After in record | After in array |\n * | --------------------- | --------------------- | ------------------ | --------------------:|\n * | `undefined \\| number` | `number` | `prop?: number` | `(number \\| null)[]` |\n * | `symbol \\| number` | `number` | `prop?: number` | `(number \\| null)[]` |\n * | `bigint \\| number` | `number` | `prop: number` | `number[]` |\n * | `undefined` | N/A `never` | (prop not present) | `null[]` |\n * | `symbol` | N/A `never` | (prop not present) | `null[]` |\n * | `bigint` | N/A `never` | N/A (prop not present) | N/A `never[]` |\n * | `bigint \\| symbol` | N/A `never` | (prop not present) | `null[]` |\n * | `bigint \\| number \\| symbol` | `number` | `prop?: number` | `(number \\| null)[]` |\n *\n * Setter and getter properties become value properties after filtering\n * although no data will be persisted assuming those properties are backed\n * by functions. If an implementation of getter/setter interface uses a\n * simple data member (of supported type), that will persist.\n *\n * Recursive types without any required modification are preserved intact.\n * Recursive types that require modification are unrolled a limited number of\n * times (currently 4) and then further instances of recursion are replaced with\n * {@link JsonTypeWith|JsonTypeWith<Options.AllowExactly[number] \"or\" Options.AllowExtensionOf>}.\n *\n * Under basic serialization, class instances become simple data objects that\n * lose hidden properties and prototypes that are required for `instanceof`\n * runtime checks. An exception is made for classes that are intersected with\n * primitive types (specifically `boolean`, `string`, and `number`) under the\n * assumption that such classes are present only as type modifiers (as would\n * be the case for branding) and not as require runtime values.\n *\n * The optional 'Options.AllowExactly' and 'Options.AllowExtensionOf'\n * parameters may be used to permit additional leaf types handled by custom\n * serialization/deserialization logic.\n *\n * @example Example usage\n *\n * ```typescript\n * function foo<T>(): JsonDeserialized<T> { ... }\n * ```\n *\n * @beta\n */\nexport type JsonDeserialized<\n\tT,\n\tOptions extends JsonDeserializedOptions = {\n\t\tAllowExactly: [];\n\t\tAllowExtensionOf: never;\n\t},\n> = InternalUtilityTypes.JsonDeserializedImpl<T, Options>;\n"]}
1
+ {"version":3,"file":"jsonDeserialized.js","sourceRoot":"","sources":["../src/jsonDeserialized.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 { InternalUtilityTypes } from \"./exposedInternalUtilityTypes.js\";\n\n/**\n * Options for {@link JsonDeserialized}.\n *\n * @public\n */\nexport interface JsonDeserializedOptions {\n\t/**\n\t * Tuple of exact types that are managed by custom deserialization logic (beyond\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse|JSON.parse}\n\t * without a reviver). Only exact types matching specification will be\n\t * preserved unaltered.\n\t *\n\t * The default value is `[]`.\n\t */\n\tAllowExactly?: unknown[];\n\n\t/**\n\t * General types that are managed by custom deserialization logic (beyond\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse|JSON.parse}\n\t * without a reviver). Any type satisfying specification will be preserved\n\t * unaltered.\n\t *\n\t * The default value is `never`.\n\t */\n\tAllowExtensionOf?: unknown;\n}\n\n/**\n * Produces a type that results from a type `T` serialized and deserialized\n * through JSON using {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify|JSON.stringify}\n * (without replacer) and {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse|JSON.parse}\n * (without reviver), respectively as base model.\n *\n * @typeParam T - The type that was serialized.\n * @typeParam Options - Options for the filter. See {@link JsonDeserializedOptions}.\n *\n * @remarks\n * Before adding use of this utility type, consider using a utility like\n * {@link https://github.com/sinclairzx81/typebox#readme | TypeBox} that allows\n * for runtime validation.\n *\n * This filter can be used to derive the expected type of a JSON deserialized\n * value whether or not the type of value serialized meets serialization\n * constraints (see {@link JsonSerializable} including serialization pitfalls).\n *\n * When used as a filter to inferred generic `T`, a compile-time error can be\n * produced trying to assign `JsonDeserialized<T>` to `T`.\n *\n * Simply deserialized JSON never contains `bigint`, `undefined`, `symbol`,\n * or function values. (Object properties which had those types before encoding\n * are omitted during serialization and thus won't be present after\n * deserialization.) Therefore, through this filter, such properties:\n *\n * - become optional with those types excluded (when there are other supported\n * types in union)\n *\n * - are removed (when nothing else in union is supported)\n *\n * - in an array are (1) replaced with `null` if `undefined`, `symbol`, and\n * function values or (2) simply removed (become `never`) if `bigint` value as\n * serialization attempts will throw.\n *\n * Examples results:\n *\n * | Before serialization | After deserialization | After in record | After in array |\n * | --------------------- | --------------------- | ------------------ | --------------------:|\n * | `undefined \\| number` | `number` | `prop?: number` | `(number \\| null)[]` |\n * | `symbol \\| number` | `number` | `prop?: number` | `(number \\| null)[]` |\n * | `bigint \\| number` | `number` | `prop: number` | `number[]` |\n * | `undefined` | N/A `never` | (prop not present) | `null[]` |\n * | `symbol` | N/A `never` | (prop not present) | `null[]` |\n * | `bigint` | N/A `never` | N/A (prop not present) | N/A `never[]` |\n * | `bigint \\| symbol` | N/A `never` | (prop not present) | `null[]` |\n * | `bigint \\| number \\| symbol` | `number` | `prop?: number` | `(number \\| null)[]` |\n *\n * Setter and getter properties become value properties after filtering\n * although no data will be persisted assuming those properties are backed\n * by functions. If an implementation of getter/setter interface uses a\n * simple data member (of supported type), that will persist.\n *\n * Recursive types without any required modification are preserved intact.\n * Recursive types that require modification are unrolled a limited number of\n * times (currently 4) and then further instances of recursion are replaced with\n * {@link JsonTypeWith|JsonTypeWith<Options.AllowExactly[number] \"or\" Options.AllowExtensionOf>}.\n *\n * Under basic serialization, class instances become simple data objects that\n * lose hidden properties and prototypes that are required for `instanceof`\n * runtime checks. An exception is made for classes that are intersected with\n * primitive types (specifically `boolean`, `string`, and `number`) under the\n * assumption that such classes are present only as type modifiers (as would\n * be the case for branding) and not as require runtime values.\n *\n * The optional 'Options.AllowExactly' and 'Options.AllowExtensionOf'\n * parameters may be used to permit additional leaf types handled by custom\n * serialization/deserialization logic.\n *\n * @example Example usage\n *\n * ```typescript\n * function foo<T>(): JsonDeserialized<T> { ... }\n * ```\n *\n * @public\n */\nexport type JsonDeserialized<\n\tT,\n\tOptions extends JsonDeserializedOptions = {\n\t\tAllowExactly: [];\n\t\tAllowExtensionOf: never;\n\t},\n> = InternalUtilityTypes.JsonDeserializedImpl<T, Options>;\n"]}
@@ -6,7 +6,7 @@ import type { InternalUtilityTypes } from "./exposedInternalUtilityTypes.js";
6
6
  /**
7
7
  * Options for {@link JsonSerializable}.
8
8
  *
9
- * @beta
9
+ * @public
10
10
  */
11
11
  export interface JsonSerializableOptions {
12
12
  /**
@@ -125,7 +125,7 @@ export interface JsonSerializableOptions {
125
125
  * proper use, that will never be an issue as any filtering of types will happen
126
126
  * before T recursion.
127
127
  *
128
- * @beta
128
+ * @public
129
129
  */
130
130
  export type JsonSerializable<T, Options extends JsonSerializableOptions = {
131
131
  AllowExactly: [];
@@ -1 +1 @@
1
- {"version":3,"file":"jsonSerializable.js","sourceRoot":"","sources":["../src/jsonSerializable.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 { InternalUtilityTypes } from \"./exposedInternalUtilityTypes.js\";\n\n/**\n * Options for {@link JsonSerializable}.\n *\n * @beta\n */\nexport interface JsonSerializableOptions {\n\t/**\n\t * Tuple of exact types that are managed by custom serialization logic (beyond\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify|JSON.stringify}\n\t * without a replacer). Only exact types matching specification will be\n\t * preserved unaltered.\n\t *\n\t * The default value is `[]`.\n\t */\n\tAllowExactly?: unknown[];\n\n\t/**\n\t * General types that are managed by custom serialization logic (beyond\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify|JSON.stringify}\n\t * without a replacer). Any type satisfying specification will be preserved\n\t * unaltered.\n\t *\n\t * The default value is `never`.\n\t */\n\tAllowExtensionOf?: unknown;\n\n\t/**\n\t * When set, inaccessible (protected and private) members throughout type T are\n\t * ignored as if not present. Otherwise, inaccessible members are considered\n\t * an error (type checking will mention `SerializationErrorPerNonPublicProperties`).\n\t *\n\t * @remarks\n\t * For this option to be set and accurately filter inaccessible members, all\n\t * inaccessible members (if any) must be either inherited, symbol keyed, or\n\t * non-enumerable.\n\t *\n\t * The default is that `IgnoreInaccessibleMembers` property is not specified,\n\t * which means that inaccessible members are considered an error, even if\n\t * they would not be serialized at runtime.\n\t */\n\tIgnoreInaccessibleMembers?: \"ignore-inaccessible-members\";\n}\n\n/**\n * Used to constrain a type `T` to types that are serializable as JSON\n * using {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify|JSON.stringify}\n * (without a replacer) as base model.\n *\n * Under typical use a compile-time error is produced if `T` contains\n * non-JsonSerializable members.\n *\n * @typeParam T - The type to be constrained.\n * @typeParam Options - Options for the filter. See {@link JsonSerializableOptions}.\n *\n * @remarks\n * Before adding use of this utility type, consider using a utility like\n * {@link https://github.com/sinclairzx81/typebox#readme | TypeBox} that allows\n * for runtime validation.\n *\n * Note that this does NOT prevent use of values with non-JSON compatible data,\n * it only prevents using values with types that include non-JSON compatible data.\n * This means that one can, for example, pass in a value typed with JSON compatible\n * interface into this filter, that could actually be a class with lots on non-JSON\n * compatible fields and methods.\n *\n * Important: `T extends JsonSerializable<T>` is incorrect (does not even compile).\n *\n * The optional `Options.Allow*` parameters may be used to permit additional leaf types\n * to support situations where a `replacer` is used to handle special values (e.g.,\n * `JsonSerializable<{ x: IFluidHandle }, { AllowExtensionOf: IFluidHandle }>`).\n *\n * Note that `JsonSerializable<T>` does not protect against the following pitfalls\n * when serializing with JSON.stringify():\n *\n * - Non-finite numbers (`NaN`, `+/-Infinity`) are coerced to `null`.\n *\n * - Prototypes and non-enumerable properties are lost.\n *\n * - `ArrayLike` types that are not arrays and are serialized as `{ length: number }`.\n *\n * - Getter and setters properties are lost. (Though appear supported.)\n *\n * - Functions with properties may be absent or the properties may be preserved\n * depending on the runtime typo of the value. (If built via Object.assign the\n * target member's type is preserved.) typeof =\\> 'function' is lost whereas when\n * typeof =\\> 'object' the properties are preserved.\n *\n * - Sparse arrays are filled with `null`.\n *\n * Also, `JsonSerializable<T>` does not prevent the construction of circular references.\n *\n * Specifying `JsonSerializable<unknown>` or `JsonSerializable<any>` yields a type\n * alias for {@link JsonTypeWith}`<never>` | {@link OpaqueJsonSerializable}`<unknown>`\n * and should not be used if precise type safety is desired.\n *\n * Class instances are indistinguishable from general objects by type checking\n * unless they have non-public members.\n *\n * - Unless `Option.IgnoreInaccessibleMembers` is used, types with non-public\n * members will result in {@link SerializationErrorPerNonPublicProperties}.\n * When `Option.IgnoreInaccessibleMembers` is `ignore-inaccessible-members`,\n * non-public (non-function) members are preserved without error, but they are\n * filtered away by the type filters and thus produce an incorrectly narrowed\n * type compared to actual data. Though such a result may be customer desired.\n *\n * - An exception is made for classes that are intersected with primitives\n * (specifically `boolean`, `number`, * and `string`). In these cases, it is\n * assumed that the class only exists as a type modifier and not as a value\n * at runtime, and thus the class is permitted as no serialization is required.\n *\n * Perhaps a https://github.com/microsoft/TypeScript/issues/22677 fix will\n * enable better support.\n *\n * @example Typical usage\n *\n * ```typescript\n * function foo<T>(value: JsonSerializable<T>) { ... }\n * ```\n *\n * @privateRemarks\n * Upon recursion, the original type T is preserved intact. This is done to prevent\n * infinite recursion and produces a technically incorrect result type. However, with\n * proper use, that will never be an issue as any filtering of types will happen\n * before T recursion.\n *\n * @beta\n */\nexport type JsonSerializable<\n\tT,\n\tOptions extends JsonSerializableOptions = {\n\t\tAllowExactly: [];\n\t\tAllowExtensionOf: never;\n\t},\n> = InternalUtilityTypes.JsonSerializableImpl<T, Options>;\n"]}
1
+ {"version":3,"file":"jsonSerializable.js","sourceRoot":"","sources":["../src/jsonSerializable.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 { InternalUtilityTypes } from \"./exposedInternalUtilityTypes.js\";\n\n/**\n * Options for {@link JsonSerializable}.\n *\n * @public\n */\nexport interface JsonSerializableOptions {\n\t/**\n\t * Tuple of exact types that are managed by custom serialization logic (beyond\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify|JSON.stringify}\n\t * without a replacer). Only exact types matching specification will be\n\t * preserved unaltered.\n\t *\n\t * The default value is `[]`.\n\t */\n\tAllowExactly?: unknown[];\n\n\t/**\n\t * General types that are managed by custom serialization logic (beyond\n\t * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify|JSON.stringify}\n\t * without a replacer). Any type satisfying specification will be preserved\n\t * unaltered.\n\t *\n\t * The default value is `never`.\n\t */\n\tAllowExtensionOf?: unknown;\n\n\t/**\n\t * When set, inaccessible (protected and private) members throughout type T are\n\t * ignored as if not present. Otherwise, inaccessible members are considered\n\t * an error (type checking will mention `SerializationErrorPerNonPublicProperties`).\n\t *\n\t * @remarks\n\t * For this option to be set and accurately filter inaccessible members, all\n\t * inaccessible members (if any) must be either inherited, symbol keyed, or\n\t * non-enumerable.\n\t *\n\t * The default is that `IgnoreInaccessibleMembers` property is not specified,\n\t * which means that inaccessible members are considered an error, even if\n\t * they would not be serialized at runtime.\n\t */\n\tIgnoreInaccessibleMembers?: \"ignore-inaccessible-members\";\n}\n\n/**\n * Used to constrain a type `T` to types that are serializable as JSON\n * using {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify|JSON.stringify}\n * (without a replacer) as base model.\n *\n * Under typical use a compile-time error is produced if `T` contains\n * non-JsonSerializable members.\n *\n * @typeParam T - The type to be constrained.\n * @typeParam Options - Options for the filter. See {@link JsonSerializableOptions}.\n *\n * @remarks\n * Before adding use of this utility type, consider using a utility like\n * {@link https://github.com/sinclairzx81/typebox#readme | TypeBox} that allows\n * for runtime validation.\n *\n * Note that this does NOT prevent use of values with non-JSON compatible data,\n * it only prevents using values with types that include non-JSON compatible data.\n * This means that one can, for example, pass in a value typed with JSON compatible\n * interface into this filter, that could actually be a class with lots on non-JSON\n * compatible fields and methods.\n *\n * Important: `T extends JsonSerializable<T>` is incorrect (does not even compile).\n *\n * The optional `Options.Allow*` parameters may be used to permit additional leaf types\n * to support situations where a `replacer` is used to handle special values (e.g.,\n * `JsonSerializable<{ x: IFluidHandle }, { AllowExtensionOf: IFluidHandle }>`).\n *\n * Note that `JsonSerializable<T>` does not protect against the following pitfalls\n * when serializing with JSON.stringify():\n *\n * - Non-finite numbers (`NaN`, `+/-Infinity`) are coerced to `null`.\n *\n * - Prototypes and non-enumerable properties are lost.\n *\n * - `ArrayLike` types that are not arrays and are serialized as `{ length: number }`.\n *\n * - Getter and setters properties are lost. (Though appear supported.)\n *\n * - Functions with properties may be absent or the properties may be preserved\n * depending on the runtime typo of the value. (If built via Object.assign the\n * target member's type is preserved.) typeof =\\> 'function' is lost whereas when\n * typeof =\\> 'object' the properties are preserved.\n *\n * - Sparse arrays are filled with `null`.\n *\n * Also, `JsonSerializable<T>` does not prevent the construction of circular references.\n *\n * Specifying `JsonSerializable<unknown>` or `JsonSerializable<any>` yields a type\n * alias for {@link JsonTypeWith}`<never>` | {@link OpaqueJsonSerializable}`<unknown>`\n * and should not be used if precise type safety is desired.\n *\n * Class instances are indistinguishable from general objects by type checking\n * unless they have non-public members.\n *\n * - Unless `Option.IgnoreInaccessibleMembers` is used, types with non-public\n * members will result in {@link SerializationErrorPerNonPublicProperties}.\n * When `Option.IgnoreInaccessibleMembers` is `ignore-inaccessible-members`,\n * non-public (non-function) members are preserved without error, but they are\n * filtered away by the type filters and thus produce an incorrectly narrowed\n * type compared to actual data. Though such a result may be customer desired.\n *\n * - An exception is made for classes that are intersected with primitives\n * (specifically `boolean`, `number`, * and `string`). In these cases, it is\n * assumed that the class only exists as a type modifier and not as a value\n * at runtime, and thus the class is permitted as no serialization is required.\n *\n * Perhaps a https://github.com/microsoft/TypeScript/issues/22677 fix will\n * enable better support.\n *\n * @example Typical usage\n *\n * ```typescript\n * function foo<T>(value: JsonSerializable<T>) { ... }\n * ```\n *\n * @privateRemarks\n * Upon recursion, the original type T is preserved intact. This is done to prevent\n * infinite recursion and produces a technically incorrect result type. However, with\n * proper use, that will never be an issue as any filtering of types will happen\n * before T recursion.\n *\n * @public\n */\nexport type JsonSerializable<\n\tT,\n\tOptions extends JsonSerializableOptions = {\n\t\tAllowExactly: [];\n\t\tAllowExtensionOf: never;\n\t},\n> = InternalUtilityTypes.JsonSerializableImpl<T, Options>;\n"]}
@@ -9,7 +9,7 @@
9
9
  * @privateRemarks type is used over interface; so inspection of type
10
10
  * result can be more informative than just the type name.
11
11
  *
12
- * @beta
12
+ * @public
13
13
  * @system
14
14
  */
15
15
  export type SerializationErrorPerUndefinedArrayElement = {
@@ -22,7 +22,7 @@ export type SerializationErrorPerUndefinedArrayElement = {
22
22
  * @privateRemarks type is used over interface; so inspection of type
23
23
  * result can be more informative than just the type name.
24
24
  *
25
- * @beta
25
+ * @public
26
26
  * @system
27
27
  */
28
28
  export type SerializationErrorPerNonPublicProperties = {
@@ -1 +1 @@
1
- {"version":3,"file":"jsonSerializationErrors.js","sourceRoot":"","sources":["../src/jsonSerializationErrors.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Type resulting from {@link JsonSerializable} use given an array with\n * `undefined` elements.\n *\n * @privateRemarks type is used over interface; so inspection of type\n * result can be more informative than just the type name.\n *\n * @beta\n * @system\n */\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport type SerializationErrorPerUndefinedArrayElement = {\n\t\"array serialization error\": \"undefined elements are not supported\";\n};\n\n/**\n * Type resulting from {@link JsonSerializable} use given a class with\n * non-public properties.\n *\n * @privateRemarks type is used over interface; so inspection of type\n * result can be more informative than just the type name.\n *\n * @beta\n * @system\n */\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport type SerializationErrorPerNonPublicProperties = {\n\t\"object serialization error\": \"non-public properties are not supported\";\n};\n"]}
1
+ {"version":3,"file":"jsonSerializationErrors.js","sourceRoot":"","sources":["../src/jsonSerializationErrors.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Type resulting from {@link JsonSerializable} use given an array with\n * `undefined` elements.\n *\n * @privateRemarks type is used over interface; so inspection of type\n * result can be more informative than just the type name.\n *\n * @public\n * @system\n */\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport type SerializationErrorPerUndefinedArrayElement = {\n\t\"array serialization error\": \"undefined elements are not supported\";\n};\n\n/**\n * Type resulting from {@link JsonSerializable} use given a class with\n * non-public properties.\n *\n * @privateRemarks type is used over interface; so inspection of type\n * result can be more informative than just the type name.\n *\n * @public\n * @system\n */\n// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\nexport type SerializationErrorPerNonPublicProperties = {\n\t\"object serialization error\": \"non-public properties are not supported\";\n};\n"]}
@@ -14,7 +14,7 @@
14
14
  * Prefer using `JsonSerializable<unknown>` or `JsonDeserialized<unknown>` over this type that
15
15
  * is an implementation detail.
16
16
  *
17
- * @beta
17
+ * @public
18
18
  */
19
19
  export type JsonTypeWith<T> = null | boolean | number | string | T | {
20
20
  [key: string | number]: JsonTypeWith<T>;
@@ -22,7 +22,7 @@ export type JsonTypeWith<T> = null | boolean | number | string | T | {
22
22
  /**
23
23
  * Portion of {@link JsonTypeWith} that is an object (including array) and not null.
24
24
  *
25
- * @beta
25
+ * @public
26
26
  */
27
27
  export type NonNullJsonObjectWith<T> = {
28
28
  [key: string | number]: JsonTypeWith<T>;
@@ -42,7 +42,7 @@ export type NonNullJsonObjectWith<T> = {
42
42
  * ```
43
43
  * does not prevent later `x = 5`. (Does prevent `x.a = 2`.)
44
44
  *
45
- * @beta
45
+ * @public
46
46
  */
47
47
  export type ReadonlyJsonTypeWith<TReadonlyAlternates> = null | boolean | number | string | TReadonlyAlternates | {
48
48
  readonly [key: string | number]: ReadonlyJsonTypeWith<TReadonlyAlternates>;
@@ -1 +1 @@
1
- {"version":3,"file":"jsonType.js","sourceRoot":"","sources":["../src/jsonType.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Type constraint for types that are likely encodable as JSON, deserializable from JSON,\n * or have a custom alternate type.\n *\n * @remarks\n * Use `JsonTypeWith<never>` for just JSON encodable/deserializable types.\n * See {@link JsonSerializable} for encoding pitfalls.\n *\n * @privateRemarks\n * Prefer using `JsonSerializable<unknown>` or `JsonDeserialized<unknown>` over this type that\n * is an implementation detail.\n *\n * @beta\n */\nexport type JsonTypeWith<T> =\n\t// eslint-disable-next-line @rushstack/no-new-null\n\t| null\n\t| boolean\n\t| number\n\t| string\n\t| T\n\t| { [key: string | number]: JsonTypeWith<T> }\n\t| JsonTypeWith<T>[];\n\n/**\n * Portion of {@link JsonTypeWith} that is an object (including array) and not null.\n *\n * @beta\n */\nexport type NonNullJsonObjectWith<T> =\n\t| { [key: string | number]: JsonTypeWith<T> }\n\t| JsonTypeWith<T>[];\n\n/**\n * Deeply immutable type that is encodable as JSON and deserializable from JSON.\n *\n * @typeParam TReadonlyAlternates - Additional [immutable] types that are supported.\n *\n * @remarks\n * If `TReadonlyAlternates` is allowed as-is. So if it is not immutable, then result type\n * is not wholly immutable.\n *\n * A `const` variable is still required to avoid top-level mutability. I.e.\n * ```typescript\n * let x: ReadonlyJsonTypeWith<never> = { a: 1 };\n * ```\n * does not prevent later `x = 5`. (Does prevent `x.a = 2`.)\n *\n * @beta\n */\nexport type ReadonlyJsonTypeWith<TReadonlyAlternates> =\n\t// eslint-disable-next-line @rushstack/no-new-null\n\t| null\n\t| boolean\n\t| number\n\t| string\n\t| TReadonlyAlternates\n\t| { readonly [key: string | number]: ReadonlyJsonTypeWith<TReadonlyAlternates> }\n\t| readonly ReadonlyJsonTypeWith<TReadonlyAlternates>[];\n\n/**\n * Portion of {@link ReadonlyJsonTypeWith} that is an object (including array) and not null.\n *\n * @internal\n */\nexport type ReadonlyNonNullJsonObjectWith<TReadonlyAlternates> =\n\t| { readonly [key: string | number]: ReadonlyJsonTypeWith<TReadonlyAlternates> }\n\t| readonly ReadonlyJsonTypeWith<TReadonlyAlternates>[];\n"]}
1
+ {"version":3,"file":"jsonType.js","sourceRoot":"","sources":["../src/jsonType.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Type constraint for types that are likely encodable as JSON, deserializable from JSON,\n * or have a custom alternate type.\n *\n * @remarks\n * Use `JsonTypeWith<never>` for just JSON encodable/deserializable types.\n * See {@link JsonSerializable} for encoding pitfalls.\n *\n * @privateRemarks\n * Prefer using `JsonSerializable<unknown>` or `JsonDeserialized<unknown>` over this type that\n * is an implementation detail.\n *\n * @public\n */\nexport type JsonTypeWith<T> =\n\t// eslint-disable-next-line @rushstack/no-new-null\n\t| null\n\t| boolean\n\t| number\n\t| string\n\t| T\n\t| { [key: string | number]: JsonTypeWith<T> }\n\t| JsonTypeWith<T>[];\n\n/**\n * Portion of {@link JsonTypeWith} that is an object (including array) and not null.\n *\n * @public\n */\nexport type NonNullJsonObjectWith<T> =\n\t| { [key: string | number]: JsonTypeWith<T> }\n\t| JsonTypeWith<T>[];\n\n/**\n * Deeply immutable type that is encodable as JSON and deserializable from JSON.\n *\n * @typeParam TReadonlyAlternates - Additional [immutable] types that are supported.\n *\n * @remarks\n * If `TReadonlyAlternates` is allowed as-is. So if it is not immutable, then result type\n * is not wholly immutable.\n *\n * A `const` variable is still required to avoid top-level mutability. I.e.\n * ```typescript\n * let x: ReadonlyJsonTypeWith<never> = { a: 1 };\n * ```\n * does not prevent later `x = 5`. (Does prevent `x.a = 2`.)\n *\n * @public\n */\nexport type ReadonlyJsonTypeWith<TReadonlyAlternates> =\n\t// eslint-disable-next-line @rushstack/no-new-null\n\t| null\n\t| boolean\n\t| number\n\t| string\n\t| TReadonlyAlternates\n\t| { readonly [key: string | number]: ReadonlyJsonTypeWith<TReadonlyAlternates> }\n\t| readonly ReadonlyJsonTypeWith<TReadonlyAlternates>[];\n\n/**\n * Portion of {@link ReadonlyJsonTypeWith} that is an object (including array) and not null.\n *\n * @internal\n */\nexport type ReadonlyNonNullJsonObjectWith<TReadonlyAlternates> =\n\t| { readonly [key: string | number]: ReadonlyJsonTypeWith<TReadonlyAlternates> }\n\t| readonly ReadonlyJsonTypeWith<TReadonlyAlternates>[];\n"]}
@@ -5,11 +5,12 @@
5
5
 
6
6
  /*
7
7
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
8
- * Generated by "flub generate entrypoints" in @fluid-tools/build-cli.
8
+ * Generated by "flub generate entrypoints --resolutionConditions require --outFileLegacyBeta legacy --outFileLegacyAlpha legacy.alpha --outDir ./dist" in @fluid-tools/build-cli.
9
9
  */
10
10
 
11
11
  export {
12
12
  // #region @public APIs
13
+ BrandedType,
13
14
  ConfigTypes,
14
15
  ErasedType,
15
16
  ExtendEventProvider,
@@ -47,8 +48,11 @@ export {
47
48
  // #endregion
48
49
 
49
50
  // #region @beta APIs
50
- BrandedType,
51
- ErasedBaseType,
51
+ ErasedBaseType,
52
+ FluidIterable,
53
+ FluidIterableIterator,
54
+ FluidMap,
55
+ FluidReadonlyMap,
52
56
  // #endregion
53
57
 
54
58
  // #region @legacyBeta APIs
package/dist/legacy.d.ts CHANGED
@@ -5,11 +5,12 @@
5
5
 
6
6
  /*
7
7
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
8
- * Generated by "flub generate entrypoints" in @fluid-tools/build-cli.
8
+ * Generated by "flub generate entrypoints --resolutionConditions require --outFileLegacyBeta legacy --outFileLegacyAlpha legacy.alpha --outDir ./dist" in @fluid-tools/build-cli.
9
9
  */
10
10
 
11
11
  export {
12
12
  // #region @public APIs
13
+ BrandedType,
13
14
  ConfigTypes,
14
15
  ErasedType,
15
16
  ExtendEventProvider,
@@ -47,8 +48,11 @@ export {
47
48
  // #endregion
48
49
 
49
50
  // #region @beta APIs
50
- BrandedType,
51
- ErasedBaseType,
51
+ ErasedBaseType,
52
+ FluidIterable,
53
+ FluidIterableIterator,
54
+ FluidMap,
55
+ FluidReadonlyMap,
52
56
  // #endregion
53
57
 
54
58
  // #region @legacyBeta APIs
@@ -17,7 +17,7 @@ import { BrandedType } from "./brandedType.js";
17
17
  * be read.
18
18
  *
19
19
  * @sealed
20
- * @beta
20
+ * @public
21
21
  */
22
22
  export declare class OpaqueJsonDeserialized<T, in out Option_AllowExactly extends unknown[] = [], out Option_AllowExtensionOf = never> extends BrandedType<"JsonDeserialized"> {
23
23
  protected readonly JsonDeserialized: {
@@ -44,7 +44,7 @@ export declare class OpaqueJsonDeserialized<T, in out Option_AllowExactly extend
44
44
  * when "instance" will be forwarded along.
45
45
  *
46
46
  * @sealed
47
- * @beta
47
+ * @public
48
48
  */
49
49
  export declare class OpaqueJsonSerializable<T, in out Option_AllowExactly extends unknown[] = [], out Option_AllowExtensionOf = never> extends BrandedType<"JsonSerializable"> {
50
50
  protected readonly JsonSerializable: {
@@ -1 +1 @@
1
- {"version":3,"file":"opaqueJson.js","sourceRoot":"","sources":["../src/opaqueJson.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAEH,qDAA+C","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { BrandedType } from \"./brandedType.js\";\n\n/**\n * Placeholder for value that is known to be JSON because it has been\n * deserialized (`T` filtered through {@link JsonDeserialized} as out value).\n *\n * @remarks\n * Usage:\n *\n * - Cast to with `as unknown as OpaqueJsonDeserialized<T>` when value `T`\n * has been filtered through {@link JsonDeserialized}.\n *\n * - Cast from with `as unknown as JsonDeserialized<T>` when \"instance\" will\n * be read.\n *\n * @sealed\n * @beta\n */\nexport declare class OpaqueJsonDeserialized<\n\tT,\n\t// These options are split from typical `JsonDeserializedOptions` as this type\n\t// requires correct variance per the two options and AllowExactly has special\n\t// variance and must be treated as invariant. In actuality, each member of the\n\t// AllowExactly tuple is invariant, but tuple as a set is covariant. This is not\n\t// expressible in TypeScript.\n\tin out Option_AllowExactly extends unknown[] = [],\n\tout Option_AllowExtensionOf = never,\n> extends BrandedType<\"JsonDeserialized\"> {\n\tprotected readonly JsonDeserialized: {\n\t\tType: T;\n\t\tOptions: {\n\t\t\tAllowExactly: Option_AllowExactly;\n\t\t\tAllowExtensionOf: Option_AllowExtensionOf;\n\t\t};\n\t};\n\t// Option_AllowExactly is covariant from above. This removes covariance, leaving only invariance.\n\tprotected readonly Option_AllowExactly_Invariance: (\n\t\tOption_AllowExactly: Option_AllowExactly,\n\t) => void;\n\tprivate constructor();\n}\n\n/**\n * Placeholder for value that is known to be JSON because it will have been\n * serialized checked (`T` filtered through {@link JsonSerializable} before \"created\").\n *\n * @remarks\n * Usage:\n *\n * - Cast to with `as unknown as OpaqueJsonSerializable<T>` when value `T`\n * has been filtered through {@link JsonSerializable}.\n *\n * - Cast from with `as unknown as JsonSerializable<T>` or `as unknown as T`\n * when \"instance\" will be forwarded along.\n *\n * @sealed\n * @beta\n */\nexport declare class OpaqueJsonSerializable<\n\tT,\n\t// These options are split from typical `JsonSerializableOptions` as this type\n\t// requires correct variance per the two options and AllowExactly has special\n\t// variance and must be treated as invariant. In actuality, each member of the\n\t// AllowExactly tuple is invariant, but tuple as a set is covariant. This is not\n\t// expressible in TypeScript.\n\tin out Option_AllowExactly extends unknown[] = [],\n\tout Option_AllowExtensionOf = never,\n\t// JsonSerializableOptions.IgnoreInaccessibleMembers is ignored\n> extends BrandedType<\"JsonSerializable\"> {\n\tprotected readonly JsonSerializable: {\n\t\tType: T;\n\t\tOptions: {\n\t\t\tAllowExactly: Option_AllowExactly;\n\t\t\tAllowExtensionOf: Option_AllowExtensionOf;\n\t\t};\n\t};\n\t// Option_AllowExactly is covariant from above. This removes covariance, leaving only invariance.\n\tprotected readonly Option_AllowExactly_Invariance: (\n\t\tOption_AllowExactly: Option_AllowExactly,\n\t) => void;\n\tprivate constructor();\n}\n"]}
1
+ {"version":3,"file":"opaqueJson.js","sourceRoot":"","sources":["../src/opaqueJson.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAEH,qDAA+C","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { BrandedType } from \"./brandedType.js\";\n\n/**\n * Placeholder for value that is known to be JSON because it has been\n * deserialized (`T` filtered through {@link JsonDeserialized} as out value).\n *\n * @remarks\n * Usage:\n *\n * - Cast to with `as unknown as OpaqueJsonDeserialized<T>` when value `T`\n * has been filtered through {@link JsonDeserialized}.\n *\n * - Cast from with `as unknown as JsonDeserialized<T>` when \"instance\" will\n * be read.\n *\n * @sealed\n * @public\n */\nexport declare class OpaqueJsonDeserialized<\n\tT,\n\t// These options are split from typical `JsonDeserializedOptions` as this type\n\t// requires correct variance per the two options and AllowExactly has special\n\t// variance and must be treated as invariant. In actuality, each member of the\n\t// AllowExactly tuple is invariant, but tuple as a set is covariant. This is not\n\t// expressible in TypeScript.\n\tin out Option_AllowExactly extends unknown[] = [],\n\tout Option_AllowExtensionOf = never,\n> extends BrandedType<\"JsonDeserialized\"> {\n\tprotected readonly JsonDeserialized: {\n\t\tType: T;\n\t\tOptions: {\n\t\t\tAllowExactly: Option_AllowExactly;\n\t\t\tAllowExtensionOf: Option_AllowExtensionOf;\n\t\t};\n\t};\n\t// Option_AllowExactly is covariant from above. This removes covariance, leaving only invariance.\n\tprotected readonly Option_AllowExactly_Invariance: (\n\t\tOption_AllowExactly: Option_AllowExactly,\n\t) => void;\n\tprivate constructor();\n}\n\n/**\n * Placeholder for value that is known to be JSON because it will have been\n * serialized checked (`T` filtered through {@link JsonSerializable} before \"created\").\n *\n * @remarks\n * Usage:\n *\n * - Cast to with `as unknown as OpaqueJsonSerializable<T>` when value `T`\n * has been filtered through {@link JsonSerializable}.\n *\n * - Cast from with `as unknown as JsonSerializable<T>` or `as unknown as T`\n * when \"instance\" will be forwarded along.\n *\n * @sealed\n * @public\n */\nexport declare class OpaqueJsonSerializable<\n\tT,\n\t// These options are split from typical `JsonSerializableOptions` as this type\n\t// requires correct variance per the two options and AllowExactly has special\n\t// variance and must be treated as invariant. In actuality, each member of the\n\t// AllowExactly tuple is invariant, but tuple as a set is covariant. This is not\n\t// expressible in TypeScript.\n\tin out Option_AllowExactly extends unknown[] = [],\n\tout Option_AllowExtensionOf = never,\n\t// JsonSerializableOptions.IgnoreInaccessibleMembers is ignored\n> extends BrandedType<\"JsonSerializable\"> {\n\tprotected readonly JsonSerializable: {\n\t\tType: T;\n\t\tOptions: {\n\t\t\tAllowExactly: Option_AllowExactly;\n\t\t\tAllowExtensionOf: Option_AllowExtensionOf;\n\t\t};\n\t};\n\t// Option_AllowExactly is covariant from above. This removes covariance, leaving only invariance.\n\tprotected readonly Option_AllowExactly_Invariance: (\n\t\tOption_AllowExactly: Option_AllowExactly,\n\t) => void;\n\tprivate constructor();\n}\n"]}
package/dist/public.d.ts CHANGED
@@ -5,11 +5,12 @@
5
5
 
6
6
  /*
7
7
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
8
- * Generated by "flub generate entrypoints" in @fluid-tools/build-cli.
8
+ * Generated by "flub generate entrypoints --resolutionConditions require --outFileLegacyBeta legacy --outFileLegacyAlpha legacy.alpha --outDir ./dist" in @fluid-tools/build-cli.
9
9
  */
10
10
 
11
11
  export {
12
12
  // #region @public APIs
13
+ BrandedType,
13
14
  ConfigTypes,
14
15
  ErasedType,
15
16
  ExtendEventProvider,
package/eslint.config.mts CHANGED
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import type { Linter } from "eslint";
7
- import { strict } from "../../../common/build/eslint-config-fluid/flat.mts";
7
+ import { strict } from "@fluidframework/eslint-config-fluid/flat.mts";
8
8
 
9
9
  const config: Linter.Config[] = [
10
10
  ...strict,
package/legacy/alpha.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  /*
7
7
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
8
- * Generated by "flub generate entrypoints" in @fluid-tools/build-cli.
8
+ * Generated by "flub generate entrypoints --outFileLegacyBeta legacy --outFileLegacyAlpha legacy.alpha --outDir ./lib --node10TypeCompat" in @fluid-tools/build-cli.
9
9
  */
10
10
 
11
11
  export * from "../lib/legacy.alpha.js";
package/legacy.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  /*
7
7
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
8
- * Generated by "flub generate entrypoints" in @fluid-tools/build-cli.
8
+ * Generated by "flub generate entrypoints --outFileLegacyBeta legacy --outFileLegacyAlpha legacy.alpha --outDir ./lib --node10TypeCompat" in @fluid-tools/build-cli.
9
9
  */
10
10
 
11
11
  export * from "./lib/legacy.js";
@@ -35,6 +35,19 @@
35
35
  *
36
36
  * This class should never exist at runtime, so it is only declared.
37
37
  *
38
+ * As this is a class and not just an interface, to match derived types, the
39
+ * declarations for any two derivatives must come from the same source - the
40
+ * same package version. If a type must cross package boundaries, as may be the
41
+ * case for cross layer types, the derived type should pick a specific version
42
+ * of core-interfaces to import BrandedType from. Exact versions are best, but
43
+ * as security best practice, use ~ specification. Consumers are expected to
44
+ * use a package manager that will produce consistency over minor patches.
45
+ * A change in version should be considered a breaking change.
46
+ *
47
+ * In the preferred derived class pattern, the derived class is subject to the
48
+ * same identity rules and might benefit from being in a type-only `-definitions`
49
+ * package. See {@link ErasedType} example comments for version stable patterns.
50
+ *
38
51
  * @example
39
52
  * Definition of two branded types with different variance:
40
53
  * ```typescript
@@ -68,7 +81,7 @@
68
81
  * }
69
82
  * ```
70
83
  *
71
- * @beta
84
+ * @public
72
85
  */
73
86
  export declare class BrandedType<out Brand> {
74
87
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"brandedType.d.ts","sourceRoot":"","sources":["../src/brandedType.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AACH,MAAM,CAAC,OAAO,OAAO,WAAW,CAAC,GAAG,CAAC,KAAK;IACzC;;;;;;;;;OASG;IACH,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,KAAK,CAAC;IAElD,SAAS;IAET;;;;;OAKG;WACW,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,IAAI,KAAK;CAChE"}
1
+ {"version":3,"file":"brandedType.d.ts","sourceRoot":"","sources":["../src/brandedType.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgFG;AACH,MAAM,CAAC,OAAO,OAAO,WAAW,CAAC,GAAG,CAAC,KAAK;IACzC;;;;;;;;;OASG;IACH,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,KAAK,CAAC;IAElD,SAAS;IAET;;;;;OAKG;WACW,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,IAAI,KAAK;CAChE"}
@@ -1 +1 @@
1
- {"version":3,"file":"brandedType.js","sourceRoot":"","sources":["../src/brandedType.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Base branded type which can be used to annotate other type.\n *\n * @remarks\n * `BrandedType` is covariant over its type parameter, which could be leveraged\n * for any generic type, but the preferred pattern is to specify variance\n * explicitly in a derived class making that clear and guaranteeing branding is\n * unique. It is convenient to have the derived class be the generic given to\n * `BrandedType`.\n *\n * ### Direct use [simple]\n *\n * Use `T & BrandedType<\"BrandName\">` to create a type conforming to `T` and\n * also branded with name \"BrandName\".\n *\n * ### Derived class use [preferred]\n *\n * Derive another class declaration and ideally add additional\n * protected properties to distinguish the type. (Private properties would\n * {@link https://github.com/microsoft/TypeScript/issues/20979#issuecomment-361432516|lose their type when exported}\n * and public properties would allow structural typing and show up on the branded\n * values.)\n *\n * Then use `T & MyBrandedType<U>` to create a type conforming to `T` and\n * also branded with the derived brand.\n *\n * ### Runtime\n *\n * Since branded types are not real value types, they will always need to be\n * created using `as` syntax and often `as unknown` first.\n *\n * This class should never exist at runtime, so it is only declared.\n *\n * @example\n * Definition of two branded types with different variance:\n * ```typescript\n * // A brand that is covariant over given T\n * declare class CovariantBrand<T> extends BrandedType<CovariantBrand<unknown>> {\n * // Does not allow unrelated or less derived CovariantBrand-ed types to be\n * // assigned. CovariantBrand<string> is not assignable to CovariantBrand<\"literal\">.\n * protected readonly CovariantBrand: T;\n * private constructor();\n * }\n * // A brand that is contravariant over given T\n * declare class ContravariantBrand<T> extends BrandedType<ContravariantBrand<unknown>> {\n * // Does not allow unrelated or more derived ContravariantBrand-ed types to be\n * // assigned. ContravariantBrand<\"literal\"> is not assignable to ContravariantBrand<string>.\n * protected readonly ContravariantBrand: (_: T) => void;\n * private constructor();\n * }\n * ```\n *\n * Applying a brand to a type through type-guard:\n * ```typescript\n * function numberIs5(n: number): n is number & CovariantBrand<5> {\n * return n === 5;\n * }\n * function onlyAccept4_5_or_6(_n: number & CovariantBrand<4 | 5 | 6>): void {}\n *\n * function example(n: number) {\n * if (numberIs5(n)) {\n * onlyAccept4_5_or_6(n); // OK: CovariantBrand<5> is assignable to CovariantBrand<4 | 5 | 6>;\n * }\n * }\n * ```\n *\n * @beta\n */\nexport declare class BrandedType<out Brand> {\n\t/**\n\t * Compile time only marker to make type checking more strict.\n\t * This method will not exist at runtime and accessing it is invalid.\n\t *\n\t * @privateRemarks\n\t * `Brand` is used as the return type of a method rather than a simple\n\t * readonly property as this allows types with two brands to be\n\t * intersected without getting `never`.\n\t * The method takes in `never` to help emphasize that it's not callable.\n\t */\n\tprotected readonly brand: (dummy: never) => Brand;\n\n\tprotected constructor();\n\n\t/**\n\t * Since this class is a compile time only type brand, `instanceof` will\n\t * never work with it. * This `Symbol.hasInstance` implementation ensures\n\t * that `instanceof` will error if used, and in TypeScript 5.3 and newer\n\t * will produce a compile time error if used.\n\t */\n\tpublic static [Symbol.hasInstance](value: never): value is never;\n}\n"]}
1
+ {"version":3,"file":"brandedType.js","sourceRoot":"","sources":["../src/brandedType.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Base branded type which can be used to annotate other type.\n *\n * @remarks\n * `BrandedType` is covariant over its type parameter, which could be leveraged\n * for any generic type, but the preferred pattern is to specify variance\n * explicitly in a derived class making that clear and guaranteeing branding is\n * unique. It is convenient to have the derived class be the generic given to\n * `BrandedType`.\n *\n * ### Direct use [simple]\n *\n * Use `T & BrandedType<\"BrandName\">` to create a type conforming to `T` and\n * also branded with name \"BrandName\".\n *\n * ### Derived class use [preferred]\n *\n * Derive another class declaration and ideally add additional\n * protected properties to distinguish the type. (Private properties would\n * {@link https://github.com/microsoft/TypeScript/issues/20979#issuecomment-361432516|lose their type when exported}\n * and public properties would allow structural typing and show up on the branded\n * values.)\n *\n * Then use `T & MyBrandedType<U>` to create a type conforming to `T` and\n * also branded with the derived brand.\n *\n * ### Runtime\n *\n * Since branded types are not real value types, they will always need to be\n * created using `as` syntax and often `as unknown` first.\n *\n * This class should never exist at runtime, so it is only declared.\n *\n * As this is a class and not just an interface, to match derived types, the\n * declarations for any two derivatives must come from the same source - the\n * same package version. If a type must cross package boundaries, as may be the\n * case for cross layer types, the derived type should pick a specific version\n * of core-interfaces to import BrandedType from. Exact versions are best, but\n * as security best practice, use ~ specification. Consumers are expected to\n * use a package manager that will produce consistency over minor patches.\n * A change in version should be considered a breaking change.\n *\n * In the preferred derived class pattern, the derived class is subject to the\n * same identity rules and might benefit from being in a type-only `-definitions`\n * package. See {@link ErasedType} example comments for version stable patterns.\n *\n * @example\n * Definition of two branded types with different variance:\n * ```typescript\n * // A brand that is covariant over given T\n * declare class CovariantBrand<T> extends BrandedType<CovariantBrand<unknown>> {\n * // Does not allow unrelated or less derived CovariantBrand-ed types to be\n * // assigned. CovariantBrand<string> is not assignable to CovariantBrand<\"literal\">.\n * protected readonly CovariantBrand: T;\n * private constructor();\n * }\n * // A brand that is contravariant over given T\n * declare class ContravariantBrand<T> extends BrandedType<ContravariantBrand<unknown>> {\n * // Does not allow unrelated or more derived ContravariantBrand-ed types to be\n * // assigned. ContravariantBrand<\"literal\"> is not assignable to ContravariantBrand<string>.\n * protected readonly ContravariantBrand: (_: T) => void;\n * private constructor();\n * }\n * ```\n *\n * Applying a brand to a type through type-guard:\n * ```typescript\n * function numberIs5(n: number): n is number & CovariantBrand<5> {\n * return n === 5;\n * }\n * function onlyAccept4_5_or_6(_n: number & CovariantBrand<4 | 5 | 6>): void {}\n *\n * function example(n: number) {\n * if (numberIs5(n)) {\n * onlyAccept4_5_or_6(n); // OK: CovariantBrand<5> is assignable to CovariantBrand<4 | 5 | 6>;\n * }\n * }\n * ```\n *\n * @public\n */\nexport declare class BrandedType<out Brand> {\n\t/**\n\t * Compile time only marker to make type checking more strict.\n\t * This method will not exist at runtime and accessing it is invalid.\n\t *\n\t * @privateRemarks\n\t * `Brand` is used as the return type of a method rather than a simple\n\t * readonly property as this allows types with two brands to be\n\t * intersected without getting `never`.\n\t * The method takes in `never` to help emphasize that it's not callable.\n\t */\n\tprotected readonly brand: (dummy: never) => Brand;\n\n\tprotected constructor();\n\n\t/**\n\t * Since this class is a compile time only type brand, `instanceof` will\n\t * never work with it. * This `Symbol.hasInstance` implementation ensures\n\t * that `instanceof` will error if used, and in TypeScript 5.3 and newer\n\t * will produce a compile time error if used.\n\t */\n\tpublic static [Symbol.hasInstance](value: never): value is never;\n}\n"]}
@@ -10,14 +10,14 @@ import type { DeepReadonlyRecursionLimit, InternalUtilityTypes, ReadonlySupporte
10
10
  * @privateRemarks
11
11
  * WeakRef should be added when lib is updated to ES2021 or later.
12
12
  *
13
- * @beta
13
+ * @public
14
14
  * @system
15
15
  */
16
16
  export type DeepReadonlySupportedGenericsDefault = Map<unknown, unknown> | Promise<unknown> | Set<unknown> | WeakMap<object, unknown> | WeakSet<object>;
17
17
  /**
18
18
  * Options for {@link DeepReadonly}.
19
19
  *
20
- * @beta
20
+ * @public
21
21
  */
22
22
  export interface DeepReadonlyOptions {
23
23
  /**
@@ -44,7 +44,7 @@ export interface DeepReadonlyOptions {
44
44
  * {@link DeepReadonlySupportedGenericsDefault} for generics that have
45
45
  * immutability applied to generic type by default.
46
46
  *
47
- * @beta
47
+ * @public
48
48
  */
49
49
  export type DeepReadonly<T, Options extends DeepReadonlyOptions = {
50
50
  DeepenedGenerics: DeepReadonlySupportedGenericsDefault;
@@ -1 +1 @@
1
- {"version":3,"file":"deepReadonly.js","sourceRoot":"","sources":["../src/deepReadonly.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\tDeepReadonlyRecursionLimit,\n\tInternalUtilityTypes,\n\tReadonlySupportedGenerics,\n} from \"./exposedInternalUtilityTypes.js\";\n\n/**\n * Default set of generic that {@link DeepReadonly} will apply deep immutability\n * to generic types.\n *\n * @privateRemarks\n * WeakRef should be added when lib is updated to ES2021 or later.\n *\n * @beta\n * @system\n */\nexport type DeepReadonlySupportedGenericsDefault =\n\t| Map<unknown, unknown>\n\t| Promise<unknown>\n\t| Set<unknown>\n\t| WeakMap<object, unknown>\n\t| WeakSet<object>;\n\n/**\n * Options for {@link DeepReadonly}.\n *\n * @beta\n */\nexport interface DeepReadonlyOptions {\n\t/**\n\t * Union of Built-in and IFluidHandle whose generics will also be made deeply immutable.\n\t *\n\t * The default value is `Map` | `Promise` | `Set` | `WeakMap` | `WeakSet`.\n\t */\n\tDeepenedGenerics?: ReadonlySupportedGenerics;\n\n\t/**\n\t * Limit on processing recursive types.\n\t *\n\t * The default value is `\"NoLimit\"`.\n\t */\n\tRecurseLimit?: DeepReadonlyRecursionLimit;\n}\n\n/**\n * Transforms type to a fully and deeply immutable type, with limitations.\n *\n * @remarks\n * This utility type is similar to a recursive `Readonly<T>`, but also\n * applies immutability to common generic types like `Map` and `Set`.\n *\n * Optionally, immutability can be applied to supported generics types. See\n * {@link DeepReadonlySupportedGenericsDefault} for generics that have\n * immutability applied to generic type by default.\n *\n * @beta\n */\nexport type DeepReadonly<\n\tT,\n\tOptions extends DeepReadonlyOptions = {\n\t\tDeepenedGenerics: DeepReadonlySupportedGenericsDefault;\n\t\tRecurseLimit: \"NoLimit\";\n\t},\n> = InternalUtilityTypes.DeepReadonlyImpl<\n\tT,\n\tOptions extends { DeepenedGenerics: unknown }\n\t\t? Options[\"DeepenedGenerics\"]\n\t\t: DeepReadonlySupportedGenericsDefault,\n\tOptions extends { RecurseLimit: DeepReadonlyRecursionLimit }\n\t\t? Options[\"RecurseLimit\"]\n\t\t: \"NoLimit\"\n>;\n"]}
1
+ {"version":3,"file":"deepReadonly.js","sourceRoot":"","sources":["../src/deepReadonly.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\tDeepReadonlyRecursionLimit,\n\tInternalUtilityTypes,\n\tReadonlySupportedGenerics,\n} from \"./exposedInternalUtilityTypes.js\";\n\n/**\n * Default set of generic that {@link DeepReadonly} will apply deep immutability\n * to generic types.\n *\n * @privateRemarks\n * WeakRef should be added when lib is updated to ES2021 or later.\n *\n * @public\n * @system\n */\nexport type DeepReadonlySupportedGenericsDefault =\n\t| Map<unknown, unknown>\n\t| Promise<unknown>\n\t| Set<unknown>\n\t| WeakMap<object, unknown>\n\t| WeakSet<object>;\n\n/**\n * Options for {@link DeepReadonly}.\n *\n * @public\n */\nexport interface DeepReadonlyOptions {\n\t/**\n\t * Union of Built-in and IFluidHandle whose generics will also be made deeply immutable.\n\t *\n\t * The default value is `Map` | `Promise` | `Set` | `WeakMap` | `WeakSet`.\n\t */\n\tDeepenedGenerics?: ReadonlySupportedGenerics;\n\n\t/**\n\t * Limit on processing recursive types.\n\t *\n\t * The default value is `\"NoLimit\"`.\n\t */\n\tRecurseLimit?: DeepReadonlyRecursionLimit;\n}\n\n/**\n * Transforms type to a fully and deeply immutable type, with limitations.\n *\n * @remarks\n * This utility type is similar to a recursive `Readonly<T>`, but also\n * applies immutability to common generic types like `Map` and `Set`.\n *\n * Optionally, immutability can be applied to supported generics types. See\n * {@link DeepReadonlySupportedGenericsDefault} for generics that have\n * immutability applied to generic type by default.\n *\n * @public\n */\nexport type DeepReadonly<\n\tT,\n\tOptions extends DeepReadonlyOptions = {\n\t\tDeepenedGenerics: DeepReadonlySupportedGenericsDefault;\n\t\tRecurseLimit: \"NoLimit\";\n\t},\n> = InternalUtilityTypes.DeepReadonlyImpl<\n\tT,\n\tOptions extends { DeepenedGenerics: unknown }\n\t\t? Options[\"DeepenedGenerics\"]\n\t\t: DeepReadonlySupportedGenericsDefault,\n\tOptions extends { RecurseLimit: DeepReadonlyRecursionLimit }\n\t\t? Options[\"RecurseLimit\"]\n\t\t: \"NoLimit\"\n>;\n"]}
@@ -12,13 +12,30 @@
12
12
  * allowing code outside of a package to have a reference/handle to something in the package in a type safe way without the package having to publicly export the types of the object.
13
13
  * This should not be confused with the more specific IFluidHandle which is also named after this design pattern.
14
14
  *
15
+ * As this is a class and not just an interface, to match derived types, the
16
+ * declarations for any two derivatives must come from the same source - the
17
+ * same package version. If a type must cross package boundaries, as may be the
18
+ * case for cross layer types, the derived type should pick a specific version
19
+ * of core-interfaces to import ErasedType from. Exact versions are best, but
20
+ * as security best practice, use ~ specification. Consumers are expected to
21
+ * use a package manager that will produce consistency over minor patches.
22
+ * A change in version should be considered a breaking change.
23
+ *
15
24
  * Recommended usage is to use `interface` instead of `type` so tooling (such as tsc and refactoring tools)
16
25
  * uses the type name instead of expanding it.
17
26
  *
18
27
  * @example
28
+ * package.json:
29
+ * ```json
30
+ * "dependencies": {
31
+ * "@fluidframework/erased-type-v1": "npm:@fluidframework/core-interfaces@~2.0.0"
32
+ * }
33
+ * ```
34
+ * source.ts:
19
35
  * ```typescript
36
+ * import { ErasedType as ErasedTypeV1 } from "@fluidframework/erased-type-v1";
20
37
  * // public sealed type
21
- * export interface ErasedMyType extends ErasedType<"myPackage.MyType"> {}
38
+ * export interface ErasedMyType extends ErasedTypeV1<"myPackage.MyType"> {}
22
39
  * // internal type
23
40
  * export interface MyType {
24
41
  * example: number;
@@ -34,6 +51,7 @@
34
51
  *
35
52
  * Do not use this class with `instanceof`: this will always be false at runtime,
36
53
  * but the compiler may think it's true in some cases.
54
+ *
37
55
  * @privateRemarks
38
56
  * For this pattern to work well it needs to be difficult for a user of the erased type to
39
57
  * implicitly use something other than a instance received from the package as an instance of the erased type in type safe code.
@@ -71,22 +89,29 @@ export declare abstract class ErasedType<out Name = unknown> {
71
89
  private constructor();
72
90
  /**
73
91
  * Since this class is a compile time only type brand, `instanceof` will never work with it.
74
- * This `Symbol.hasInstance` implementation ensures that `instanceof` will error if used,
75
- * and in TypeScript 5.3 and newer will produce a compile time error if used.
92
+ * This `Symbol.hasInstance` declaration (no definition) ensures that `instanceof` will
93
+ * produce `ReferenceError` if used at runtime. And in TypeScript 5.3 and newer will produce
94
+ * a compile time error if used.
76
95
  */
77
96
  static [Symbol.hasInstance](value: never): value is never;
78
97
  }
79
98
  /**
80
99
  * Used to mark a `@sealed` interface in a strongly typed way to prevent external implementations.
100
+ *
81
101
  * @remarks
82
102
  * This is an alternative to {@link ErasedType} which is more ergonomic to implement in the case where the implementation can extend `ErasedTypeImplementation`.
83
103
  *
84
104
  * Users of interfaces extending this should never refer to anything about this class:
85
105
  * migrating the type branding to another mechanism, like {@link ErasedType} should be considered a non-breaking change.
106
+ *
107
+ * @see {@link ErasedType} for version compatibility notes.
108
+ *
86
109
  * @privateRemarks
87
110
  * Implement interfaces which extend this by sub-classing {@link ErasedTypeImplementation}.
88
111
  *
89
112
  * This class should only be a `type` package export, preventing users from extending it directly.
113
+ * But since {@link ErasedTypeImplementation} does extend it, an implementation
114
+ * of the constructor must be provided, unlike {@link ErasedType}.
90
115
  *
91
116
  * Since {@link ErasedTypeImplementation} is exported as `@internal`, this restricts implementations of the sealed interfaces to users of `@internal` APIs, which should be anything within this release group.
92
117
  * Any finer grained restrictions can be done as documentation, but not type enforced.
@@ -1 +1 @@
1
- {"version":3,"file":"erasedType.d.ts","sourceRoot":"","sources":["../src/erasedType.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,8BAAsB,UAAU,CAAC,GAAG,CAAC,IAAI,GAAG,OAAO;IAClD;;;;;;OAMG;IACH,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAE5C;;OAEG;IACH,OAAO;IAEP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