@fluidframework/presence 2.10.0-307399

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 (255) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +216 -0
  3. package/dist/alpha.d.ts +58 -0
  4. package/dist/baseTypes.d.ts +24 -0
  5. package/dist/baseTypes.d.ts.map +1 -0
  6. package/dist/baseTypes.js +7 -0
  7. package/dist/baseTypes.js.map +1 -0
  8. package/dist/container-definitions/containerExtensions.d.ts +137 -0
  9. package/dist/container-definitions/containerExtensions.d.ts.map +1 -0
  10. package/dist/container-definitions/containerExtensions.js +7 -0
  11. package/dist/container-definitions/containerExtensions.js.map +1 -0
  12. package/dist/container-definitions/index.d.ts +7 -0
  13. package/dist/container-definitions/index.d.ts.map +1 -0
  14. package/dist/container-definitions/index.js +7 -0
  15. package/dist/container-definitions/index.js.map +1 -0
  16. package/dist/container-definitions/runtime.d.ts +12 -0
  17. package/dist/container-definitions/runtime.d.ts.map +1 -0
  18. package/dist/container-definitions/runtime.js +7 -0
  19. package/dist/container-definitions/runtime.js.map +1 -0
  20. package/dist/core-interfaces/exposedUtilityTypes.d.ts +446 -0
  21. package/dist/core-interfaces/exposedUtilityTypes.d.ts.map +1 -0
  22. package/dist/core-interfaces/exposedUtilityTypes.js +11 -0
  23. package/dist/core-interfaces/exposedUtilityTypes.js.map +1 -0
  24. package/dist/core-interfaces/index.d.ts +10 -0
  25. package/dist/core-interfaces/index.d.ts.map +1 -0
  26. package/dist/core-interfaces/index.js +7 -0
  27. package/dist/core-interfaces/index.js.map +1 -0
  28. package/dist/core-interfaces/jsonDeserialized.d.ts +109 -0
  29. package/dist/core-interfaces/jsonDeserialized.d.ts.map +1 -0
  30. package/dist/core-interfaces/jsonDeserialized.js +7 -0
  31. package/dist/core-interfaces/jsonDeserialized.js.map +1 -0
  32. package/dist/core-interfaces/jsonSerializable.d.ts +120 -0
  33. package/dist/core-interfaces/jsonSerializable.d.ts.map +1 -0
  34. package/dist/core-interfaces/jsonSerializable.js +7 -0
  35. package/dist/core-interfaces/jsonSerializable.js.map +1 -0
  36. package/dist/core-interfaces/jsonSerializationErrors.d.ts +31 -0
  37. package/dist/core-interfaces/jsonSerializationErrors.d.ts.map +1 -0
  38. package/dist/core-interfaces/jsonSerializationErrors.js +7 -0
  39. package/dist/core-interfaces/jsonSerializationErrors.js.map +1 -0
  40. package/dist/core-interfaces/jsonType.d.ts +29 -0
  41. package/dist/core-interfaces/jsonType.d.ts.map +1 -0
  42. package/dist/core-interfaces/jsonType.js +7 -0
  43. package/dist/core-interfaces/jsonType.js.map +1 -0
  44. package/dist/datastorePresenceManagerFactory.d.ts +48 -0
  45. package/dist/datastorePresenceManagerFactory.d.ts.map +1 -0
  46. package/dist/datastorePresenceManagerFactory.js +79 -0
  47. package/dist/datastorePresenceManagerFactory.js.map +1 -0
  48. package/dist/datastoreSupport.d.ts +31 -0
  49. package/dist/datastoreSupport.d.ts.map +1 -0
  50. package/dist/datastoreSupport.js +82 -0
  51. package/dist/datastoreSupport.js.map +1 -0
  52. package/dist/events/events.d.ts +198 -0
  53. package/dist/events/events.d.ts.map +1 -0
  54. package/dist/events/events.js +157 -0
  55. package/dist/events/events.js.map +1 -0
  56. package/dist/experimentalAccess.d.ts +15 -0
  57. package/dist/experimentalAccess.d.ts.map +1 -0
  58. package/dist/experimentalAccess.js +46 -0
  59. package/dist/experimentalAccess.js.map +1 -0
  60. package/dist/exposedInternalTypes.d.ts +100 -0
  61. package/dist/exposedInternalTypes.d.ts.map +1 -0
  62. package/dist/exposedInternalTypes.js +19 -0
  63. package/dist/exposedInternalTypes.js.map +1 -0
  64. package/dist/exposedUtilityTypes.d.ts +63 -0
  65. package/dist/exposedUtilityTypes.d.ts.map +1 -0
  66. package/dist/exposedUtilityTypes.js +7 -0
  67. package/dist/exposedUtilityTypes.js.map +1 -0
  68. package/dist/index.d.ts +22 -0
  69. package/dist/index.d.ts.map +1 -0
  70. package/dist/index.js +21 -0
  71. package/dist/index.js.map +1 -0
  72. package/dist/internalTypes.d.ts +39 -0
  73. package/dist/internalTypes.d.ts.map +1 -0
  74. package/dist/internalTypes.js +14 -0
  75. package/dist/internalTypes.js.map +1 -0
  76. package/dist/latestMapValueManager.d.ts +182 -0
  77. package/dist/latestMapValueManager.d.ts.map +1 -0
  78. package/dist/latestMapValueManager.js +206 -0
  79. package/dist/latestMapValueManager.js.map +1 -0
  80. package/dist/latestValueControls.d.ts +44 -0
  81. package/dist/latestValueControls.d.ts.map +1 -0
  82. package/dist/latestValueControls.js +28 -0
  83. package/dist/latestValueControls.js.map +1 -0
  84. package/dist/latestValueManager.d.ts +69 -0
  85. package/dist/latestValueManager.d.ts.map +1 -0
  86. package/dist/latestValueManager.js +100 -0
  87. package/dist/latestValueManager.js.map +1 -0
  88. package/dist/latestValueTypes.d.ts +44 -0
  89. package/dist/latestValueTypes.d.ts.map +1 -0
  90. package/dist/latestValueTypes.js +7 -0
  91. package/dist/latestValueTypes.js.map +1 -0
  92. package/dist/notificationsManager.d.ts +101 -0
  93. package/dist/notificationsManager.d.ts.map +1 -0
  94. package/dist/notificationsManager.js +82 -0
  95. package/dist/notificationsManager.js.map +1 -0
  96. package/dist/package.json +15 -0
  97. package/dist/presence.d.ts +180 -0
  98. package/dist/presence.d.ts.map +1 -0
  99. package/dist/presence.js +23 -0
  100. package/dist/presence.js.map +1 -0
  101. package/dist/presenceDatastoreManager.d.ts +91 -0
  102. package/dist/presenceDatastoreManager.d.ts.map +1 -0
  103. package/dist/presenceDatastoreManager.js +248 -0
  104. package/dist/presenceDatastoreManager.js.map +1 -0
  105. package/dist/presenceManager.d.ts +20 -0
  106. package/dist/presenceManager.d.ts.map +1 -0
  107. package/dist/presenceManager.js +104 -0
  108. package/dist/presenceManager.js.map +1 -0
  109. package/dist/presenceStates.d.ts +78 -0
  110. package/dist/presenceStates.d.ts.map +1 -0
  111. package/dist/presenceStates.js +182 -0
  112. package/dist/presenceStates.js.map +1 -0
  113. package/dist/stateDatastore.d.ts +35 -0
  114. package/dist/stateDatastore.d.ts.map +1 -0
  115. package/dist/stateDatastore.js +26 -0
  116. package/dist/stateDatastore.js.map +1 -0
  117. package/dist/systemWorkspace.d.ts +51 -0
  118. package/dist/systemWorkspace.d.ts.map +1 -0
  119. package/dist/systemWorkspace.js +180 -0
  120. package/dist/systemWorkspace.js.map +1 -0
  121. package/dist/types.d.ts +92 -0
  122. package/dist/types.d.ts.map +1 -0
  123. package/dist/types.js +8 -0
  124. package/dist/types.js.map +1 -0
  125. package/dist/valueManager.d.ts +19 -0
  126. package/dist/valueManager.d.ts.map +1 -0
  127. package/dist/valueManager.js +26 -0
  128. package/dist/valueManager.js.map +1 -0
  129. package/lib/alpha.d.ts +58 -0
  130. package/lib/baseTypes.d.ts +24 -0
  131. package/lib/baseTypes.d.ts.map +1 -0
  132. package/lib/baseTypes.js +6 -0
  133. package/lib/baseTypes.js.map +1 -0
  134. package/lib/container-definitions/containerExtensions.d.ts +137 -0
  135. package/lib/container-definitions/containerExtensions.d.ts.map +1 -0
  136. package/lib/container-definitions/containerExtensions.js +6 -0
  137. package/lib/container-definitions/containerExtensions.js.map +1 -0
  138. package/lib/container-definitions/index.d.ts +7 -0
  139. package/lib/container-definitions/index.d.ts.map +1 -0
  140. package/lib/container-definitions/index.js +6 -0
  141. package/lib/container-definitions/index.js.map +1 -0
  142. package/lib/container-definitions/runtime.d.ts +12 -0
  143. package/lib/container-definitions/runtime.d.ts.map +1 -0
  144. package/lib/container-definitions/runtime.js +6 -0
  145. package/lib/container-definitions/runtime.js.map +1 -0
  146. package/lib/core-interfaces/exposedUtilityTypes.d.ts +446 -0
  147. package/lib/core-interfaces/exposedUtilityTypes.d.ts.map +1 -0
  148. package/lib/core-interfaces/exposedUtilityTypes.js +10 -0
  149. package/lib/core-interfaces/exposedUtilityTypes.js.map +1 -0
  150. package/lib/core-interfaces/index.d.ts +10 -0
  151. package/lib/core-interfaces/index.d.ts.map +1 -0
  152. package/lib/core-interfaces/index.js +6 -0
  153. package/lib/core-interfaces/index.js.map +1 -0
  154. package/lib/core-interfaces/jsonDeserialized.d.ts +109 -0
  155. package/lib/core-interfaces/jsonDeserialized.d.ts.map +1 -0
  156. package/lib/core-interfaces/jsonDeserialized.js +6 -0
  157. package/lib/core-interfaces/jsonDeserialized.js.map +1 -0
  158. package/lib/core-interfaces/jsonSerializable.d.ts +120 -0
  159. package/lib/core-interfaces/jsonSerializable.d.ts.map +1 -0
  160. package/lib/core-interfaces/jsonSerializable.js +6 -0
  161. package/lib/core-interfaces/jsonSerializable.js.map +1 -0
  162. package/lib/core-interfaces/jsonSerializationErrors.d.ts +31 -0
  163. package/lib/core-interfaces/jsonSerializationErrors.d.ts.map +1 -0
  164. package/lib/core-interfaces/jsonSerializationErrors.js +6 -0
  165. package/lib/core-interfaces/jsonSerializationErrors.js.map +1 -0
  166. package/lib/core-interfaces/jsonType.d.ts +29 -0
  167. package/lib/core-interfaces/jsonType.d.ts.map +1 -0
  168. package/lib/core-interfaces/jsonType.js +6 -0
  169. package/lib/core-interfaces/jsonType.js.map +1 -0
  170. package/lib/datastorePresenceManagerFactory.d.ts +48 -0
  171. package/lib/datastorePresenceManagerFactory.d.ts.map +1 -0
  172. package/lib/datastorePresenceManagerFactory.js +75 -0
  173. package/lib/datastorePresenceManagerFactory.js.map +1 -0
  174. package/lib/datastoreSupport.d.ts +31 -0
  175. package/lib/datastoreSupport.d.ts.map +1 -0
  176. package/lib/datastoreSupport.js +77 -0
  177. package/lib/datastoreSupport.js.map +1 -0
  178. package/lib/events/events.d.ts +198 -0
  179. package/lib/events/events.d.ts.map +1 -0
  180. package/lib/events/events.js +152 -0
  181. package/lib/events/events.js.map +1 -0
  182. package/lib/experimentalAccess.d.ts +15 -0
  183. package/lib/experimentalAccess.d.ts.map +1 -0
  184. package/lib/experimentalAccess.js +42 -0
  185. package/lib/experimentalAccess.js.map +1 -0
  186. package/lib/exposedInternalTypes.d.ts +100 -0
  187. package/lib/exposedInternalTypes.d.ts.map +1 -0
  188. package/lib/exposedInternalTypes.js +16 -0
  189. package/lib/exposedInternalTypes.js.map +1 -0
  190. package/lib/exposedUtilityTypes.d.ts +63 -0
  191. package/lib/exposedUtilityTypes.d.ts.map +1 -0
  192. package/lib/exposedUtilityTypes.js +6 -0
  193. package/lib/exposedUtilityTypes.js.map +1 -0
  194. package/lib/index.d.ts +22 -0
  195. package/lib/index.d.ts.map +1 -0
  196. package/lib/index.js +11 -0
  197. package/lib/index.js.map +1 -0
  198. package/lib/internalTypes.d.ts +39 -0
  199. package/lib/internalTypes.d.ts.map +1 -0
  200. package/lib/internalTypes.js +11 -0
  201. package/lib/internalTypes.js.map +1 -0
  202. package/lib/latestMapValueManager.d.ts +182 -0
  203. package/lib/latestMapValueManager.d.ts.map +1 -0
  204. package/lib/latestMapValueManager.js +202 -0
  205. package/lib/latestMapValueManager.js.map +1 -0
  206. package/lib/latestValueControls.d.ts +44 -0
  207. package/lib/latestValueControls.d.ts.map +1 -0
  208. package/lib/latestValueControls.js +24 -0
  209. package/lib/latestValueControls.js.map +1 -0
  210. package/lib/latestValueManager.d.ts +69 -0
  211. package/lib/latestValueManager.d.ts.map +1 -0
  212. package/lib/latestValueManager.js +96 -0
  213. package/lib/latestValueManager.js.map +1 -0
  214. package/lib/latestValueTypes.d.ts +44 -0
  215. package/lib/latestValueTypes.d.ts.map +1 -0
  216. package/lib/latestValueTypes.js +6 -0
  217. package/lib/latestValueTypes.js.map +1 -0
  218. package/lib/notificationsManager.d.ts +101 -0
  219. package/lib/notificationsManager.d.ts.map +1 -0
  220. package/lib/notificationsManager.js +78 -0
  221. package/lib/notificationsManager.js.map +1 -0
  222. package/lib/presence.d.ts +180 -0
  223. package/lib/presence.d.ts.map +1 -0
  224. package/lib/presence.js +20 -0
  225. package/lib/presence.js.map +1 -0
  226. package/lib/presenceDatastoreManager.d.ts +91 -0
  227. package/lib/presenceDatastoreManager.d.ts.map +1 -0
  228. package/lib/presenceDatastoreManager.js +244 -0
  229. package/lib/presenceDatastoreManager.js.map +1 -0
  230. package/lib/presenceManager.d.ts +20 -0
  231. package/lib/presenceManager.d.ts.map +1 -0
  232. package/lib/presenceManager.js +100 -0
  233. package/lib/presenceManager.js.map +1 -0
  234. package/lib/presenceStates.d.ts +78 -0
  235. package/lib/presenceStates.d.ts.map +1 -0
  236. package/lib/presenceStates.js +177 -0
  237. package/lib/presenceStates.js.map +1 -0
  238. package/lib/stateDatastore.d.ts +35 -0
  239. package/lib/stateDatastore.d.ts.map +1 -0
  240. package/lib/stateDatastore.js +21 -0
  241. package/lib/stateDatastore.js.map +1 -0
  242. package/lib/systemWorkspace.d.ts +51 -0
  243. package/lib/systemWorkspace.d.ts.map +1 -0
  244. package/lib/systemWorkspace.js +176 -0
  245. package/lib/systemWorkspace.js.map +1 -0
  246. package/lib/tsdoc-metadata.json +11 -0
  247. package/lib/types.d.ts +92 -0
  248. package/lib/types.d.ts.map +1 -0
  249. package/lib/types.js +7 -0
  250. package/lib/types.js.map +1 -0
  251. package/lib/valueManager.d.ts +19 -0
  252. package/lib/valueManager.d.ts.map +1 -0
  253. package/lib/valueManager.js +21 -0
  254. package/lib/valueManager.js.map +1 -0
  255. package/package.json +175 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exposedUtilityTypes.js","sourceRoot":"","sources":["../../src/core-interfaces/exposedUtilityTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH;;GAEG;AACH,MAAM,qBAAqB,GAAkB,MAAM,CAAC,gBAAgB,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @rushstack/no-new-null */\n\nimport type {\n\tSerializationErrorPerNonPublicProperties,\n\tSerializationErrorPerUndefinedArrayElement,\n} from \"./jsonSerializationErrors.js\";\nimport type { JsonTypeWith, NonNullJsonObjectWith } from \"./jsonType.js\";\n\n/**\n * Unique symbol for recursion meta-typing.\n */\nconst RecursionMarkerSymbol: unique symbol = Symbol(\"recursion here\");\n\n/**\n * Collection of utility types that are not intended to be used/imported\n * directly outside of this package.\n *\n * @privateRemarks\n * There are ony three intentional exports from this module:\n * - {@link InternalUtilityTypes.IfSameType | IfSameType}\n * - {@link InternalUtilityTypes.JsonDeserializedImpl | JsonDeserializedImpl }\n * - {@link InternalUtilityTypes.JsonSerializableImpl | JsonSerializableImpl }\n *\n * api-extractor will allow `export` to be removed from others but generates\n * api-report a little oddly with a rogue `{};` floating at end of namespace\n * in api.md file. It will promote all of the support types to appear as\n * exported anyway. All in namespace are left exported to avoid api-extractor\n * potentially failing to validate other modules correctly.\n *\n * @alpha\n * @system\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace InternalUtilityTypes {\n\t/**\n\t * Meta-type for controlling filtering utilities.\n\t *\n\t * @system\n\t */\n\texport interface FilterControls {\n\t\t/**\n\t\t * Exact types that are managed by custom serialization/deserialization\n\t\t * logic (beyond JSON.stringify and JSON.parse without replacers/revivers).\n\t\t * Only exact types matching specification will be preserved unaltered.\n\t\t *\n\t\t * @privateRemarks\n\t\t * This could be a tuple of types that would support replacing exactly\n\t\t * specified unions. However that would not be useful in the context of\n\t\t * serializers/deserializers as those must work only with the specific\n\t\t * data given at runtime and have no knowledge of the alternate data\n\t\t * that could be encountered in that space.\n\t\t *\n\t\t * Such union matching is only known to be useful for matching recursion\n\t\t * cases.\n\t\t */\n\t\tAllowExactly: unknown;\n\n\t\t/**\n\t\t * General types that are managed by custom serialization/deserialization\n\t\t * logic (beyond JSON.stringify and JSON.parse without replacers/revivers).\n\t\t * Any type satisfying specification will be preserved unaltered.\n\t\t */\n\t\tAllowExtensionOf: unknown;\n\t}\n\n\t/**\n\t * Returns non-symbol keys for optional properties of an object type.\n\t *\n\t * For homomorphic mapping use with `as` to filter. Example:\n\t * `[K in keyof T as OptionalNonSymbolKeysOf<T, K>]: ...`\n\t *\n\t * @system\n\t */\n\texport type OptionalNonSymbolKeysOf<\n\t\tT extends object,\n\t\tKeys extends keyof T = keyof T,\n\t> = Exclude<\n\t\t{\n\t\t\t[K in Keys]: T extends Record<K, T[K]> ? never : K;\n\t\t}[Keys],\n\t\tundefined | symbol\n\t>;\n\n\t/**\n\t * Returns non-symbol keys for required properties of an object type.\n\t *\n\t * For homomorphic mapping use with `as` to filter. Example:\n\t * `[K in keyof T as RequiredNonSymbolKeysOf<T, K>]: ...`\n\t *\n\t * @system\n\t */\n\texport type RequiredNonSymbolKeysOf<\n\t\tT extends object,\n\t\tKeys extends keyof T = keyof T,\n\t> = Exclude<\n\t\t{\n\t\t\t[K in Keys]: T extends Record<K, T[K]> ? K : never;\n\t\t}[Keys],\n\t\tundefined | symbol\n\t>;\n\n\t/**\n\t * Returns Result.WhenSomethingDeserializable if T is sometimes at least a\n\t * partially deserializable type, otherwise Result.WhenNeverDeserializable.\n\t * Fully not deserializable (bigints, symbols, undefined and functions without\n\t * other properties less overlap with T*Exception) produce Result.WhenNeverDeserializable.\n\t * An object would have a defined result even if parts of its content are\n\t * not deserializable.\n\t *\n\t * @param Result - Result type with two properties. One property must always\n\t * be `never` as `T` maybe a union of never deserializable and at least\n\t * partially deserializable types and the result is a union of Result.*.\n\t *\n\t * @privateRemarks\n\t * If `Result.WhenSomethingDeserializable` was `true` and\n\t * `Result.WhenNeverDeserializable` was `false`, then the return type\n\t * for type `T` would be `boolean` for a sometimes deserializable type.\n\t *\n\t * @system\n\t */\n\texport type TestDeserializabilityOf<\n\t\tT,\n\t\tTExactException,\n\t\tTExtendsException,\n\t\tResult extends\n\t\t\t| { WhenSomethingDeserializable: unknown; WhenNeverDeserializable: never }\n\t\t\t| { WhenSomethingDeserializable: never; WhenNeverDeserializable: unknown },\n\t> = /* ensure working with more than never */ T extends never\n\t\t? /* never => */ Result[\"WhenNeverDeserializable\"]\n\t\t: /* check for extends exception */ T extends TExtendsException\n\t\t\t? /* extends exception => */ Result[\"WhenSomethingDeserializable\"]\n\t\t\t: /* no extends exception => check for exact exception */ IfExactTypeInUnion<\n\t\t\t\t\tT,\n\t\t\t\t\tTExactException,\n\t\t\t\t\t/* exact exception => */ Result[\"WhenSomethingDeserializable\"],\n\t\t\t\t\t/* no exception => check for only non-serializable value types */ T extends\n\t\t\t\t\t\t| bigint\n\t\t\t\t\t\t| symbol\n\t\t\t\t\t\t| undefined\n\t\t\t\t\t\t? /* not serializable => */ Result[\"WhenNeverDeserializable\"]\n\t\t\t\t\t\t: // eslint-disable-next-line @typescript-eslint/ban-types\n\t\t\t\t\t\t\tT extends Function\n\t\t\t\t\t\t\t? ExtractFunctionFromIntersection<T> extends {\n\t\t\t\t\t\t\t\t\tclassification: \"exactly Function\";\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t? /* not serializable => */ Result[\"WhenNeverDeserializable\"]\n\t\t\t\t\t\t\t\t: /* at least partially serializable */ Result[\"WhenSomethingDeserializable\"]\n\t\t\t\t\t\t\t: /* at least partially serializable */ Result[\"WhenSomethingDeserializable\"]\n\t\t\t\t>;\n\n\t/**\n\t * Similar to `Exclude` but only excludes exact `U`s from `T`\n\t * rather than any type that extends `U`.\n\t *\n\t * @system\n\t */\n\texport type ExcludeExactly<T, U> = IfSameType<T, U, never, T>;\n\n\t/**\n\t * Returns non-symbol keys for defined, (likely) serializable properties of an\n\t * object type. Keys with fully unsupported properties (undefined, symbol, and\n\t * bigint) and sometimes unsupported (functions) are excluded. An exception to\n\t * that is when there are supported types in union with just bigint.\n\t *\n\t * For homomorphic mapping use with `as` to filter. Example:\n\t * `[K in keyof T as NonSymbolWithDeserializablePropertyOf<T, never, never, K>]: ...`\n\t *\n\t * @system\n\t */\n\texport type NonSymbolWithDeserializablePropertyOf<\n\t\tT extends object,\n\t\tTExactException,\n\t\tTExtendsException,\n\t\tKeys extends keyof T = keyof T,\n\t> = Exclude<\n\t\t{\n\t\t\t[K in Keys]: /* all possible types that aren't already allowed */\n\t\t\tExcludeExactly<\n\t\t\t\tExclude<T[K], TExtendsException>,\n\t\t\t\tTExactException\n\t\t\t> extends infer PossibleTypeLessAllowed\n\t\t\t\t? /* extract types that might lead to missing property */\n\t\t\t\t\tExtract<\n\t\t\t\t\t\tPossibleTypeLessAllowed,\n\t\t\t\t\t\t/* types that might lead to missing property, except `bigint` */\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/ban-types\n\t\t\t\t\t\tundefined | symbol | Function\n\t\t\t\t\t> extends never\n\t\t\t\t\t? /* all types are supported plus possibly `bigint` => */\n\t\t\t\t\t\t/* check for only `bigint` remaining */ IfSameType<\n\t\t\t\t\t\t\tPossibleTypeLessAllowed,\n\t\t\t\t\t\t\tbigint,\n\t\t\t\t\t\t\t/* only `bigint` => nothing supported */ never,\n\t\t\t\t\t\t\t/* exclusively supported types (and maybe `bigint`) or exactly `never` */\n\t\t\t\t\t\t\t/* => check for `never` */ T[K] extends never ? never : K\n\t\t\t\t\t\t>\n\t\t\t\t\t: /* value might not be supported => exclude K */ never\n\t\t\t\t: never;\n\t\t}[Keys],\n\t\tundefined | symbol\n\t>;\n\n\t/**\n\t * Returns non-symbol keys for partially supported properties of an object type.\n\t * Keys with only unsupported properties (undefined, symbol, bigint, and\n\t * functions without other properties) are excluded.\n\t *\n\t * For homomorphic mapping use with `as` to filter. Example:\n\t * `[K in keyof T as NonSymbolWithPossiblyDeserializablePropertyOf<T, never, never, K>]: ...`\n\t *\n\t * @system\n\t */\n\texport type NonSymbolWithPossiblyDeserializablePropertyOf<\n\t\tT extends object,\n\t\tTExactException,\n\t\tTExtendsException,\n\t\tKeys extends keyof T = keyof T,\n\t> = Exclude<\n\t\t{\n\t\t\t[K in Keys]: Extract<\n\t\t\t\t/* all possible types that aren't already allowed */\n\t\t\t\tExcludeExactly<Exclude<T[K], TExtendsException>, TExactException>,\n\t\t\t\t/* types that might lead to missing property */\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/ban-types\n\t\t\t\tundefined | symbol | Function\n\t\t\t> extends never\n\t\t\t\t? /* exclusively supported types or exactly `never` */ never\n\t\t\t\t: /* at least some unsupported type => check for any supported */ TestDeserializabilityOf<\n\t\t\t\t\t\tT[K],\n\t\t\t\t\t\tTExactException,\n\t\t\t\t\t\tTExtendsException,\n\t\t\t\t\t\t{ WhenSomethingDeserializable: K; WhenNeverDeserializable: never }\n\t\t\t\t\t>;\n\t\t}[Keys],\n\t\tundefined | symbol\n\t>;\n\n\t/**\n\t * Filters a type `T` for `undefined` that is not viable in an array (or tuple) that\n\t * must go through JSON serialization.\n\t * If `T` is `undefined`, then error type {@link SerializationErrorPerUndefinedArrayElement}\n\t * is returned with hopes of being informative.\n\t *\n\t * @system\n\t */\n\texport type JsonForSerializableArrayItem<\n\t\tT,\n\t\tControls extends FilterControls,\n\t\tTAncestorTypes extends unknown[],\n\t\tTBlessed,\n\t> = /* Some initial filtering must be provided before a test for undefined. */\n\t/* These tests are expected to match those in JsonSerializableImpl. */\n\t/* test for 'any' */ boolean extends (T extends never ? true : false)\n\t\t? /* 'any' => */ TBlessed\n\t\t: /* test for 'unknown' */ unknown extends T\n\t\t\t? /* 'unknown' => */ TBlessed\n\t\t\t: /* test for exact recursion */ IfExactTypeInTuple<\n\t\t\t\t\tT,\n\t\t\t\t\tTAncestorTypes,\n\t\t\t\t\t/* recursion; stop here => */ T,\n\t\t\t\t\t/* test for JSON primitive types or given alternative */ T extends\n\t\t\t\t\t\t| null\n\t\t\t\t\t\t| boolean\n\t\t\t\t\t\t| number\n\t\t\t\t\t\t| string\n\t\t\t\t\t\t| Controls[\"AllowExtensionOf\"]\n\t\t\t\t\t\t? /* primitive types or alternative => */ T\n\t\t\t\t\t\t: /* test for exact alternative */ IfExactTypeInUnion<\n\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\tControls[\"AllowExactly\"],\n\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\t/* test for undefined possibility */ undefined extends T\n\t\t\t\t\t\t\t\t\t? /* undefined | ... => */ SerializationErrorPerUndefinedArrayElement\n\t\t\t\t\t\t\t\t\t: TBlessed\n\t\t\t\t\t\t\t>\n\t\t\t\t>;\n\n\t/**\n\t * Filters a type `T` for types that become null through JSON serialization.\n\t *\n\t * @system\n\t */\n\texport type JsonForDeserializedArrayItem<\n\t\tT,\n\t\tControls extends FilterControls,\n\t\tTBlessed,\n\t> = /* Some initial filtering must be provided before a test for undefined, symbol, or function. */\n\t/* These tests are expected to match those in JsonDeserializedImpl. */\n\t/* test for 'any' */ boolean extends (T extends never ? true : false)\n\t\t? /* 'any' => */ TBlessed\n\t\t: /* test for 'unknown' */ unknown extends T\n\t\t\t? /* 'unknown' => */ TBlessed\n\t\t\t: /* test for JSON primitive types or general alternative */ T extends\n\t\t\t\t\t\t| null\n\t\t\t\t\t\t| boolean\n\t\t\t\t\t\t| number\n\t\t\t\t\t\t| string\n\t\t\t\t\t\t| Controls[\"AllowExtensionOf\"]\n\t\t\t\t? /* primitive or replaced types => */ T\n\t\t\t\t: /* test for exact alternative */ IfExactTypeInUnion<\n\t\t\t\t\t\tT,\n\t\t\t\t\t\tControls[\"AllowExactly\"],\n\t\t\t\t\t\t/* exactly replaced => */ T,\n\t\t\t\t\t\t/* test for known types that become null */ T extends undefined | symbol\n\t\t\t\t\t\t\t? /* => */ null\n\t\t\t\t\t\t\t: // eslint-disable-next-line @typescript-eslint/ban-types\n\t\t\t\t\t\t\t\tT extends Function\n\t\t\t\t\t\t\t\t? ExtractFunctionFromIntersection<T> extends {\n\t\t\t\t\t\t\t\t\t\tclassification: \"exactly Function\";\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t? null\n\t\t\t\t\t\t\t\t\t: null | TBlessed\n\t\t\t\t\t\t\t\t: TBlessed\n\t\t\t\t\t>;\n\n\t/**\n\t * Checks for a type that is simple class of number and string indexed types to numbers and strings.\n\t *\n\t * @system\n\t */\n\texport type IfEnumLike<\n\t\tT extends object,\n\t\tEnumLike = never,\n\t\tNotEnumLike = unknown,\n\t> = T extends readonly (infer _)[]\n\t\t? /* array => */ NotEnumLike\n\t\t: // eslint-disable-next-line @typescript-eslint/ban-types\n\t\t\tT extends Function\n\t\t\t? /* function => */ NotEnumLike\n\t\t\t: T extends {\n\t\t\t\t\t\t// all numerical indices should refer to a string\n\t\t\t\t\t\treadonly [i: number]: string;\n\t\t\t\t\t\t// string indices may be string or number\n\t\t\t\t\t\treadonly [p: string]: number | string;\n\t\t\t\t\t\t// no symbol indices are allowed\n\t\t\t\t\t\treadonly [s: symbol]: never;\n\t\t\t\t\t}\n\t\t\t\t? /* test for a never or any property */ true extends {\n\t\t\t\t\t\t[K in keyof T]: T[K] extends never ? true : never;\n\t\t\t\t\t}[keyof T]\n\t\t\t\t\t? NotEnumLike\n\t\t\t\t\t: EnumLike\n\t\t\t\t: NotEnumLike;\n\n\t/**\n\t * Test for type equality\n\t *\n\t * @returns IfSame if identical and IfDifferent otherwise.\n\t *\n\t * Implementation derived from https://github.com/Microsoft/TypeScript/issues/27024#issuecomment-421529650\n\t *\n\t * @system\n\t */\n\texport type IfSameType<X, Y, IfSame = unknown, IfDifferent = never> = (<T>() => T extends X\n\t\t? 1\n\t\t: 2) extends <T>() => T extends Y ? 1 : 2\n\t\t? IfSame\n\t\t: IfDifferent;\n\n\t/**\n\t * Test for type equality with tuple of other types.\n\t *\n\t * @typeParam T - Type to find in Tuple.\n\t * @typeParam Tuple - Tuple of types to test against.\n\t * @typeParam IfMatch - Type to return if match is found.\n\t * @typeParam IfNoMatch - Type to return if no match is found.\n\t *\n\t * @privateRemarks\n\t * Tests for an extact match of `T` in `Tuple[0]`. If not found,\n\t * recurses with the remainder of the tuple.\n\t */\n\texport type IfExactTypeInTuple<\n\t\tT,\n\t\tTuple extends unknown[],\n\t\tIfMatch = unknown,\n\t\tIfNoMatch = never,\n\t> = Tuple extends [infer First, ...infer Rest]\n\t\t? IfSameType<T, First, IfMatch, IfExactTypeInTuple<T, Rest, IfMatch, IfNoMatch>>\n\t\t: IfNoMatch;\n\n\t/**\n\t * Test for type equality with union of other types.\n\t *\n\t * @typeParam T - Type to find in Union. If this is itself a union, then all types must be found in Union.\n\t * @typeParam Union - Union of types to test against.\n\t * @typeParam IfMatch - Type to return if match is found.\n\t * @typeParam IfNoMatch - Type to return if no match is found.\n\t *\n\t * @remarks\n\t * In a recursive context, use {@link InternalUtilityTypes.IfExactTypeInTuple} to manage ancestry.\n\t *\n\t * @privateRemarks\n\t * Perhaps it is a Typescript defect but a simple check that `T` is `never`\n\t * via `T extends never` does not work as expected in this context.\n\t * Workaround using `IfSameType<..., never,...>`.\n\t * @system\n\t */\n\texport type IfExactTypeInUnion<T, Union, IfMatch = unknown, IfNoMatch = never> = IfSameType<\n\t\tT,\n\t\tnever,\n\t\t/* T is never => */ IfSameType<Union, never, IfMatch, IfNoMatch>,\n\t\t/* T is NOT never => */ IfSameType<T, Extract<Union, T>, IfMatch, IfNoMatch>\n\t>;\n\n\t/**\n\t * Test for type equality\n\t *\n\t * @returns `true` if identical and `false` otherwise.\n\t *\n\t * @system\n\t */\n\texport type IsSameType<X, Y> = IfSameType<X, Y, true, false>;\n\n\t/**\n\t * Checks that type is exactly `object`.\n\t *\n\t * @system\n\t */\n\texport type IsExactlyObject<T extends object> = IsSameType<T, object>;\n\n\t/**\n\t * Creates a simple object type from an intersection of multiple.\n\t * @privateRemarks\n\t * `T extends Record` within the implementation encourages tsc to process\n\t * intersections within unions.\n\t *\n\t * @system\n\t */\n\texport type FlattenIntersection<T extends Record<string | number | symbol, unknown>> =\n\t\tT extends Record<string | number | symbol, unknown>\n\t\t\t? {\n\t\t\t\t\t[K in keyof T]: T[K];\n\t\t\t\t}\n\t\t\t: T;\n\n\t/**\n\t * Extracts Function portion from an intersection (&) type returning\n\t * the extracted portion in the `function` property or `unknown` if\n\t * no function is found.\n\t * The returned `classification` property has one of three values:\n\t * - \"no Function\" if the type is not a function.\n\t * - \"exactly Function\" if the type is exactly a function.\n\t * - \"Function and more\" if the type is a function and has other properties.\n\t *\n\t * @system\n\t */\n\texport type ExtractFunctionFromIntersection<T extends object> = (T extends new (\n\t\t...args: infer A\n\t) => infer R\n\t\t? new (\n\t\t\t\t...args: A\n\t\t\t) => R\n\t\t: unknown) &\n\t\t(T extends (...args: infer A) => infer R\n\t\t\t? (...args: A) => R\n\t\t\t: unknown) extends infer Functional\n\t\t? {\n\t\t\t\tclassification: unknown extends Functional\n\t\t\t\t\t? \"no Function\"\n\t\t\t\t\t: Functional extends Required<T>\n\t\t\t\t\t\t? \"exactly Function\"\n\t\t\t\t\t\t: \"Function and more\";\n\t\t\t\tfunction: Functional;\n\t\t\t}\n\t\t: never;\n\n\t/**\n\t * Returns `Filtered` & any Function intersection from `Original`.\n\t * If `Original` is exactly a Function, then `Filtered` is left out\n\t * under the assumption that it is not useful/applicable.\n\t *\n\t * @system\n\t */\n\texport type FilterPreservingFunction<\n\t\tOriginal extends object,\n\t\tFiltered,\n\t> = ExtractFunctionFromIntersection<Original> extends {\n\t\tclassification: infer TClassification;\n\t\tfunction: infer TFunction;\n\t}\n\t\t? TClassification extends \"exactly Function\"\n\t\t\t? TFunction\n\t\t\t: TFunction & Filtered\n\t\t: never;\n\n\t/**\n\t * Replaces any instance where a type T recurses into itself or a portion of\n\t * itself with TReplacement.\n\t *\n\t * @typeParam T - Type to process.\n\t * @typeParam TRecursionMarker - Replacement marker type.\n\t * @typeParam Controls - Allowances are preserved as-is.\n\t * @typeParam TAncestorTypes - Types that are ancestors of T.\n\t * @typeParam TNextAncestor - Set exactly to T. This is passed separately\n\t * such that T union types remain intact as exact ancestors.\n\t *\n\t * @remarks\n\t * Filtering applied to class instances with non-public properties will not\n\t * preserve the class instance unless those classes are known and listed as\n\t * allowances via `Controls`.\n\t *\n\t * @privateRemarks\n\t * This implementation handles functions including function with properties.\n\t * There are no known cases where replacing recursion under such types make\n\t * a difference. Either the function (whole type) is allowed by the Json\n\t * filters or function is not allowed at all.\n\t * If the function portion is found to be problematic later, then could use\n\t * `T extends Function ? T : ...` to ignore function objects.\n\t *\n\t * @system\n\t */\n\texport type ReplaceRecursionWithMarkerAndPreserveAllowances<\n\t\tT,\n\t\tTRecursionMarker,\n\t\tControls extends FilterControls,\n\t\tTAncestorTypes extends unknown[] = [],\n\t\tTNextAncestor = T,\n\t> = /* test for recursion */\n\tIfExactTypeInTuple<T, TAncestorTypes, true, \"no match\"> extends true\n\t\t? /* recursion => use replacement */ TRecursionMarker\n\t\t: /* force union separation hereafter */ T extends infer _\n\t\t\t? /* test for recursion among union elements */\n\t\t\t\tIfExactTypeInTuple<T, TAncestorTypes, true, \"no match\"> extends true\n\t\t\t\t? TRecursionMarker\n\t\t\t\t: /* test for general allowance */ T extends Controls[\"AllowExtensionOf\"]\n\t\t\t\t\t? /* allowed extension type => */ T\n\t\t\t\t\t: /* test for exact allowance */ IfExactTypeInUnion<\n\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\tControls[\"AllowExactly\"],\n\t\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\t\t\"no match\"\n\t\t\t\t\t\t\t> extends true\n\t\t\t\t\t\t? /* exact allowed type => */ T\n\t\t\t\t\t\t: T extends object\n\t\t\t\t\t\t\t? FilterPreservingFunction<\n\t\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t[K in keyof T]: ReplaceRecursionWithMarkerAndPreserveAllowances<\n\t\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\t\tTRecursionMarker,\n\t\t\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t\t\t[TNextAncestor, ...TAncestorTypes]\n\t\t\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t: /* non-object => T as is */ T\n\t\t\t: never;\n\n\t/**\n\t * Replaces any instances of \"allowed\" types and recursion within with `never`.\n\t *\n\t * @typeParam T - Type to process.\n\t * @typeParam Controls - Allowances to replace.\n\t * @typeParam TAncestorTypes - Types that are ancestors of T.\n\t * @typeParam TNextAncestor - Set exactly to T. This is passed separately\n\t * such that T union types remain intact as exact ancestors.\n\t *\n\t * @system\n\t */\n\texport type ReplaceAllowancesAndRecursionWithNever<\n\t\tT,\n\t\tControls extends FilterControls,\n\t\tTAncestorTypes extends unknown[] = [],\n\t\tTNextAncestor = T,\n\t> = /* test for exact recursion first */ IfExactTypeInTuple<\n\t\tT,\n\t\tTAncestorTypes,\n\t\ttrue,\n\t\t\"no match\"\n\t> extends true\n\t\t? /* recursion => */ never\n\t\t: /* test for general allowance (also forces union separation) */ T extends Controls[\"AllowExtensionOf\"]\n\t\t\t? /* allowed extension type => */ never\n\t\t\t: /* test for exact allowance */ IfExactTypeInUnion<\n\t\t\t\t\t\tT,\n\t\t\t\t\t\tControls[\"AllowExactly\"],\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\"no match\"\n\t\t\t\t\t> extends true\n\t\t\t\t? /* exact allowed type => */ never\n\t\t\t\t: /* test for recursion among union elements */ IfExactTypeInTuple<\n\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\tTAncestorTypes,\n\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\t\"no match\"\n\t\t\t\t\t\t> extends true\n\t\t\t\t\t? /* recursion => */ never\n\t\t\t\t\t: T extends object\n\t\t\t\t\t\t? FilterPreservingFunction<\n\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t[K in keyof T]: ReplaceAllowancesAndRecursionWithNever<\n\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t\t[TNextAncestor, ...TAncestorTypes]\n\t\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t: /* non-object => T as is */ T;\n\n\t/**\n\t * Test for non-public properties (which can only exist on class instance types).\n\t *\n\t * Returns `HasNonPublic` if `T` deeply may contain a private or protected field\n\t * and `OnlyPublics` otherwise.\n\t *\n\t * @remarks\n\t * Compare original (unprocessed) to filtered case that has `never` where\n\t * recursing or where allowed exception types are used.\n\t *\n\t * Note that this a test of the type and not the actual data. So, if an\n\t * interface is given as `T` where implemented by a class, any private or\n\t * protected fields within the class will not be detected.\n\t *\n\t * @system\n\t */\n\texport type IfNonPublicProperties<\n\t\tT,\n\t\tControls extends FilterControls,\n\t\tHasNonPublic = never,\n\t\tOnlyPublics = unknown,\n\t> = ReplaceAllowancesAndRecursionWithNever<T, Controls> extends T\n\t\t? OnlyPublics\n\t\t: HasNonPublic;\n\n\t// #region JsonSerializable implementation\n\n\t/**\n\t * Outer implementation of {@link JsonSerializable} handling meta cases\n\t * like classes (with non-public properties).\n\t *\n\t * @system\n\t */\n\texport type JsonSerializableImpl<\n\t\tT,\n\t\tOptions extends Partial<FilterControls> & {\n\t\t\tIgnoreInaccessibleMembers?: \"ignore-inaccessible-members\";\n\t\t},\n\t\tTAncestorTypes extends unknown[] = [],\n\t\tTNextAncestor = T,\n\t> = /* Build Controls from Options filling in defaults for any missing properties */\n\t{\n\t\tAllowExactly: Options extends { AllowExactly: unknown } ? Options[\"AllowExactly\"] : never;\n\t\tAllowExtensionOf: Options extends { AllowExtensionOf: unknown }\n\t\t\t? Options[\"AllowExtensionOf\"]\n\t\t\t: never;\n\t} extends infer Controls\n\t\t? /* Controls should always satisfy FilterControls, but Typescript wants a check */\n\t\t\tControls extends FilterControls\n\t\t\t? /* test for 'any' */ boolean extends (T extends never ? true : false)\n\t\t\t\t? /* 'any' => */ JsonTypeWith<Controls[\"AllowExactly\"] | Controls[\"AllowExtensionOf\"]>\n\t\t\t\t: Options[\"IgnoreInaccessibleMembers\"] extends \"ignore-inaccessible-members\"\n\t\t\t\t\t? JsonSerializableFilter<T, Controls, TAncestorTypes, TNextAncestor>\n\t\t\t\t\t: /* test for non-public properties (class instance type) */\n\t\t\t\t\t\tIfNonPublicProperties<\n\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\"found non-publics\",\n\t\t\t\t\t\t\t\t\"only publics\"\n\t\t\t\t\t\t\t> extends \"found non-publics\"\n\t\t\t\t\t\t? /* hidden props => test if it is array properties that are the problem */ T extends readonly (infer _)[]\n\t\t\t\t\t\t\t? /* array => */ {\n\t\t\t\t\t\t\t\t\t/* use homomorphic mapped type to preserve tuple type */\n\t\t\t\t\t\t\t\t\t[K in keyof T]: JsonSerializableImpl<\n\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t\t[TNextAncestor, ...TAncestorTypes]\n\t\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: /* not array => error */ SerializationErrorPerNonPublicProperties\n\t\t\t\t\t\t: /* no hidden properties => apply filtering => */ JsonSerializableFilter<\n\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\tTAncestorTypes,\n\t\t\t\t\t\t\t\tTNextAncestor\n\t\t\t\t\t\t\t>\n\t\t\t: never /* FilterControls assert else; should never be reached */\n\t\t: never /* unreachable else for infer */;\n\n\t/**\n\t * Core implementation of {@link JsonSerializable}.\n\t *\n\t * @privateRemarks\n\t * Note that `T` becomes an Controls.AllowExtensionOf type during recursion.\n\t * Filtering through a single layer of recursion is all that is required\n\t * when using in prescribed filter scenario. Controls.AllowExtensionOf must\n\t * be used instead of Controls.AllowExactly to avoid possibly deep and\n\t * infinite recursion from tsc. Checking extension of is sufficient as all\n\t * extended types from the recursion type are more specific and and would\n\t * be considered before reaching the more general T currently being processed.\n\t *\n\t * @system\n\t */\n\texport type JsonSerializableFilter<\n\t\tT,\n\t\tControls extends FilterControls,\n\t\tTAncestorTypes extends unknown[],\n\t\tTNextAncestor = T,\n\t> = /* test for 'any' */ boolean extends (T extends never ? true : false)\n\t\t? /* 'any' => */ JsonTypeWith<Controls[\"AllowExactly\"] | Controls[\"AllowExtensionOf\"]>\n\t\t: /* test for 'unknown' */ unknown extends T\n\t\t\t? /* 'unknown' => */ JsonTypeWith<\n\t\t\t\t\tControls[\"AllowExactly\"] | Controls[\"AllowExtensionOf\"]\n\t\t\t\t>\n\t\t\t: /* test for recursion */ IfExactTypeInTuple<\n\t\t\t\t\t\tT,\n\t\t\t\t\t\tTAncestorTypes,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\"no match\"\n\t\t\t\t\t> extends true\n\t\t\t\t? /* exact recursion; stop here => */ T\n\t\t\t\t: /* test for JSON Encodable primitive types or given alternate base */ T extends\n\t\t\t\t\t\t\t| null\n\t\t\t\t\t\t\t| boolean\n\t\t\t\t\t\t\t| number\n\t\t\t\t\t\t\t| string\n\t\t\t\t\t\t\t| Controls[\"AllowExtensionOf\"]\n\t\t\t\t\t? /* primitive types or alternate => */ T\n\t\t\t\t\t: /* test for exact alternate */ IfExactTypeInUnion<\n\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\tControls[\"AllowExactly\"],\n\t\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\t\t\"no match\"\n\t\t\t\t\t\t\t> extends true\n\t\t\t\t\t\t? /* exact alternate type => */ T\n\t\t\t\t\t\t: // eslint-disable-next-line @typescript-eslint/ban-types\n\t\t\t\t\t\t\t/* test for not a function */ Extract<T, Function> extends never\n\t\t\t\t\t\t\t? /* not a function => test for object */ T extends object\n\t\t\t\t\t\t\t\t? /* object => test for array */ T extends readonly (infer _)[]\n\t\t\t\t\t\t\t\t\t? /* array => */ {\n\t\t\t\t\t\t\t\t\t\t\t/* array items may not not allow undefined */\n\t\t\t\t\t\t\t\t\t\t\t/* use homomorphic mapped type to preserve tuple type */\n\t\t\t\t\t\t\t\t\t\t\t[K in keyof T]: JsonForSerializableArrayItem<\n\t\t\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t\t\t\tTAncestorTypes,\n\t\t\t\t\t\t\t\t\t\t\t\tJsonSerializableFilter<\n\t\t\t\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t\t\t\t\t[TNextAncestor, ...TAncestorTypes]\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t: /* not an array => test for exactly `object` */ IsExactlyObject<T> extends true\n\t\t\t\t\t\t\t\t\t\t? /* `object` => */ NonNullJsonObjectWith<\n\t\t\t\t\t\t\t\t\t\t\t\tControls[\"AllowExactly\"] | Controls[\"AllowExtensionOf\"]\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t: /* test for enum like types */ IfEnumLike<T> extends never\n\t\t\t\t\t\t\t\t\t\t\t? /* enum or similar simple type (return as-is) => */ T\n\t\t\t\t\t\t\t\t\t\t\t: /* property bag => */ FlattenIntersection<\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t/* required properties are recursed and may not have undefined values. */\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t[K in keyof T as RequiredNonSymbolKeysOf<\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tK\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t>]-?: undefined extends T[K]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[\"error required property may not allow undefined value\"]: never;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t: JsonSerializableFilter<\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[TNextAncestor, ...TAncestorTypes]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t\t\t\t\t\t\t} & {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t/* optional properties are recursed and, when exactOptionalPropertyTypes is\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t false, are allowed to preserve undefined value type. */\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t[K in keyof T as OptionalNonSymbolKeysOf<\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tK\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t>]?: JsonSerializableFilter<\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[TNextAncestor, ...TAncestorTypes]\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t\t\t\t\t\t\t} & {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t/* symbol properties are rejected */\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t[K in keyof T & symbol]: never;\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t: /* not an object => */ never\n\t\t\t\t\t\t\t: /* function => */ never;\n\n\t// #endregion\n\n\t// #region JsonDeserialized implementation\n\n\t/**\n\t * Sentinel type for use when marking points of recursion (in a recursive type).\n\t * Type is expected to be unique, though no lengths is taken to ensure that.\n\t *\n\t * @system\n\t */\n\texport interface RecursionMarker {\n\t\t[RecursionMarkerSymbol]: typeof RecursionMarkerSymbol;\n\t}\n\n\t/**\n\t * Recursion limit is the count of `+` that prefix it when string.\n\t *\n\t * @system\n\t */\n\texport type RecursionLimit = `+${string}` | 0;\n\n\t/**\n\t * Outer implementation of {@link JsonDeserialized} handling meta cases\n\t * like recursive types.\n\t *\n\t * @privateRemarks\n\t * This utility is reentrant and will process a type `T` up to RecurseLimit.\n\t *\n\t * @system\n\t */\n\texport type JsonDeserializedImpl<\n\t\tT,\n\t\tOptions extends Partial<FilterControls>,\n\t\tRecurseLimit extends RecursionLimit = \"++++\" /* 4 */,\n\t> = /* Build Controls from Options filling in defaults for any missing properties */\n\t{\n\t\tAllowExactly: Options extends { AllowExactly: unknown } ? Options[\"AllowExactly\"] : never;\n\t\tAllowExtensionOf: Options extends { AllowExtensionOf: unknown }\n\t\t\t? Options[\"AllowExtensionOf\"]\n\t\t\t: never;\n\t} extends infer Controls\n\t\t? /* Controls should always satisfy FilterControls, but Typescript wants a check */\n\t\t\tControls extends FilterControls\n\t\t\t? /* test for 'any' */ boolean extends (T extends never ? true : false)\n\t\t\t\t? /* 'any' => */ JsonTypeWith<Controls[\"AllowExactly\"] | Controls[\"AllowExtensionOf\"]>\n\t\t\t\t: /* infer non-recursive version of T */ ReplaceRecursionWithMarkerAndPreserveAllowances<\n\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\tRecursionMarker,\n\t\t\t\t\t\t\tControls\n\t\t\t\t\t\t> extends infer TNoRecursionAndOnlyPublics\n\t\t\t\t\t? /* test for no change from filtered type */ IsSameType<\n\t\t\t\t\t\t\tTNoRecursionAndOnlyPublics,\n\t\t\t\t\t\t\tJsonDeserializedFilter<\n\t\t\t\t\t\t\t\tTNoRecursionAndOnlyPublics,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tAllowExactly: Controls[\"AllowExactly\"] | RecursionMarker;\n\t\t\t\t\t\t\t\t\tAllowExtensionOf: Controls[\"AllowExtensionOf\"];\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t0\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t> extends true\n\t\t\t\t\t\t? /* same (no filtering needed) => test for non-public\n\t\t\t\t\t\t properties (class instance type) */\n\t\t\t\t\t\t\tIfNonPublicProperties<\n\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\"found non-publics\",\n\t\t\t\t\t\t\t\t\"only publics\"\n\t\t\t\t\t\t\t> extends \"found non-publics\"\n\t\t\t\t\t\t\t? /* hidden props => apply filtering to avoid retaining\n\t\t\t\t\t\t\t exact class except for any classes in allowances => */\n\t\t\t\t\t\t\t\tJsonDeserializedFilter<\n\t\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t// Note that use of RecurseLimit may not be needed here\n\t\t\t\t\t\t\t\t\t// could have an adverse effect on correctness if there\n\t\t\t\t\t\t\t\t\t// several ancestor types that require modification and\n\t\t\t\t\t\t\t\t\t// are peeling away the limit. In such a case, the limit\n\t\t\t\t\t\t\t\t\t// will be used for the problems and result is already\n\t\t\t\t\t\t\t\t\t// messy; so deferring full understanding of the problems\n\t\t\t\t\t\t\t\t\t// that could arise from a reset and being conservative.\n\t\t\t\t\t\t\t\t\tRecurseLimit\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t: /* no hidden properties => deserialized T is just T */\n\t\t\t\t\t\t\t\tT\n\t\t\t\t\t\t: /* filtering is needed => */ JsonDeserializedFilter<T, Controls, RecurseLimit>\n\t\t\t\t\t: /* unreachable else for infer */ never\n\t\t\t: never /* FilterControls assert else; should never be reached */\n\t\t: never /* unreachable else for infer */;\n\n\t/**\n\t * Recurses T applying {@link InternalUtilityTypes.JsonDeserializedFilter} up to RecurseLimit times.\n\t *\n\t * @system\n\t */\n\texport type JsonDeserializedRecursion<\n\t\tT,\n\t\tControls extends FilterControls,\n\t\tRecurseLimit extends RecursionLimit,\n\t\tTAncestorTypes,\n\t> = T extends TAncestorTypes\n\t\t? RecurseLimit extends `+${infer RecursionRemainder}`\n\t\t\t? /* Now that specific recursion is found, process that recursive type\n\t\t\t directly to avoid any collateral damage from ancestor type that\n\t\t\t required modification. */\n\t\t\t\tJsonDeserializedImpl<\n\t\t\t\t\tT,\n\t\t\t\t\tControls,\n\t\t\t\t\tRecursionRemainder extends RecursionLimit ? RecursionRemainder : 0\n\t\t\t\t>\n\t\t\t: JsonTypeWith<Controls[\"AllowExactly\"] | Controls[\"AllowExtensionOf\"]>\n\t\t: JsonDeserializedFilter<T, Controls, RecurseLimit, TAncestorTypes | T>;\n\n\t/**\n\t * Core implementation of {@link JsonDeserialized}.\n\t *\n\t * @system\n\t */\n\texport type JsonDeserializedFilter<\n\t\tT,\n\t\tControls extends FilterControls,\n\t\tRecurseLimit extends RecursionLimit,\n\t\tTAncestorTypes = T /* Always start with self as ancestor; otherwise recursion limit appears one greater */,\n\t> = /* test for 'any' */ boolean extends (T extends never ? true : false)\n\t\t? /* 'any' => */ JsonTypeWith<Controls[\"AllowExactly\"] | Controls[\"AllowExtensionOf\"]>\n\t\t: /* test for 'unknown' */ unknown extends T\n\t\t\t? /* 'unknown' => */ JsonTypeWith<\n\t\t\t\t\tControls[\"AllowExactly\"] | Controls[\"AllowExtensionOf\"]\n\t\t\t\t>\n\t\t\t: /* test for deserializable primitive types or given alternate base */ T extends\n\t\t\t\t\t\t| null\n\t\t\t\t\t\t| boolean\n\t\t\t\t\t\t| number\n\t\t\t\t\t\t| string\n\t\t\t\t\t\t| Controls[\"AllowExtensionOf\"]\n\t\t\t\t? /* primitive types or alternate => */ T\n\t\t\t\t: /* test for given exact alternate */ IfExactTypeInUnion<\n\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\tControls[\"AllowExactly\"],\n\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\t\"not found\"\n\t\t\t\t\t\t> extends true\n\t\t\t\t\t? /* exact alternate type => */ T\n\t\t\t\t\t: /* test for object */ T extends object\n\t\t\t\t\t\t? /* object => */ ExtractFunctionFromIntersection<T> extends {\n\t\t\t\t\t\t\t\tclassification: \"exactly Function\";\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t? /* exactly function => */ never\n\t\t\t\t\t\t\t: /* not exactly a function (Function portion, if any, is omitted) */\n\t\t\t\t\t\t\t\t/* => test for array */ T extends readonly (infer _)[]\n\t\t\t\t\t\t\t\t? /* array => */ {\n\t\t\t\t\t\t\t\t\t\t/* array items may not not allow undefined */\n\t\t\t\t\t\t\t\t\t\t/* use homomorphic mapped type to preserve tuple type */\n\t\t\t\t\t\t\t\t\t\t[K in keyof T]: JsonForDeserializedArrayItem<\n\t\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t\t\tJsonDeserializedRecursion<T[K], Controls, RecurseLimit, TAncestorTypes>\n\t\t\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t: /* not an array => test for exactly `object` */ IsExactlyObject<T> extends true\n\t\t\t\t\t\t\t\t\t? /* `object` => */ NonNullJsonObjectWith<\n\t\t\t\t\t\t\t\t\t\t\tControls[\"AllowExactly\"] | Controls[\"AllowExtensionOf\"]\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t: /* test for enum like types */ IfEnumLike<T> extends never\n\t\t\t\t\t\t\t\t\t\t? /* enum or similar simple type (return as-is) => */ T\n\t\t\t\t\t\t\t\t\t\t: /* property bag => */ FlattenIntersection<\n\t\t\t\t\t\t\t\t\t\t\t\t/* properties with symbol keys or wholly unsupported values are removed */\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t/* properties with defined values are recursed */\n\t\t\t\t\t\t\t\t\t\t\t\t\t[K in keyof T as NonSymbolWithDeserializablePropertyOf<\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tControls[\"AllowExactly\"],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tControls[\"AllowExtensionOf\"],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tK\n\t\t\t\t\t\t\t\t\t\t\t\t\t>]: JsonDeserializedRecursion<\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tRecurseLimit,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tTAncestorTypes\n\t\t\t\t\t\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t\t\t\t\t\t} & {\n\t\t\t\t\t\t\t\t\t\t\t\t\t/* properties that may have undefined values are optional */\n\t\t\t\t\t\t\t\t\t\t\t\t\t[K in keyof T as NonSymbolWithPossiblyDeserializablePropertyOf<\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tT,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tControls[\"AllowExactly\"],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tControls[\"AllowExtensionOf\"],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tK\n\t\t\t\t\t\t\t\t\t\t\t\t\t>]?: JsonDeserializedRecursion<\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tT[K],\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tControls,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tRecurseLimit,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tTAncestorTypes\n\t\t\t\t\t\t\t\t\t\t\t\t\t>;\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t: /* not an object => */ never;\n\n\t// #endregion\n}\n"]}
@@ -0,0 +1,10 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export type { JsonDeserialized, JsonDeserializedOptions } from "./jsonDeserialized.js";
6
+ export type { JsonSerializable, JsonSerializableOptions } from "./jsonSerializable.js";
7
+ export type { SerializationErrorPerNonPublicProperties, SerializationErrorPerUndefinedArrayElement, } from "./jsonSerializationErrors.js";
8
+ export type { JsonTypeWith, NonNullJsonObjectWith } from "./jsonType.js";
9
+ export type * from "./exposedUtilityTypes.js";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core-interfaces/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,YAAY,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACvF,YAAY,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACvF,YAAY,EACX,wCAAwC,EACxC,0CAA0C,GAC1C,MAAM,8BAA8B,CAAC;AACtC,YAAY,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAGzE,mBAAmB,0BAA0B,CAAC"}
@@ -0,0 +1,6 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core-interfaces/index.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport type { JsonDeserialized, JsonDeserializedOptions } from \"./jsonDeserialized.js\";\nexport type { JsonSerializable, JsonSerializableOptions } from \"./jsonSerializable.js\";\nexport type {\n\tSerializationErrorPerNonPublicProperties,\n\tSerializationErrorPerUndefinedArrayElement,\n} from \"./jsonSerializationErrors.js\";\nexport type { JsonTypeWith, NonNullJsonObjectWith } from \"./jsonType.js\";\n\n// eslint-disable-next-line no-restricted-syntax\nexport type * from \"./exposedUtilityTypes.js\";\n"]}
@@ -0,0 +1,109 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { InternalUtilityTypes } from "./exposedUtilityTypes.js";
6
+ /**
7
+ * Options for {@link JsonDeserialized}.
8
+ *
9
+ * @alpha
10
+ */
11
+ export interface JsonDeserializedOptions {
12
+ /**
13
+ * Exact types that are managed by custom deserialization logic (beyond
14
+ * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse|JSON.parse}
15
+ * without a reviver). Only exact types matching specification will be
16
+ * preserved unaltered.
17
+ *
18
+ * The default value is `never`.
19
+ */
20
+ AllowExactly?: unknown;
21
+ /**
22
+ * General types that are managed by custom deserialization logic (beyond
23
+ * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse|JSON.parse}
24
+ * without a reviver). Any type satisfying specification will be preserved
25
+ * unaltered.
26
+ *
27
+ * The default value is `never`.
28
+ */
29
+ AllowExtensionOf?: unknown;
30
+ }
31
+ /**
32
+ * Produces a type that results from a type `T` serialized and deserialized
33
+ * through JSON using {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify|JSON.stringify}
34
+ * (without replacer) and {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse|JSON.parse}
35
+ * (without reviver), respectively as base model.
36
+ *
37
+ * @typeParam T - The type that was serialized.
38
+ * @typeParam Options - Options for the filter. See {@link JsonDeserializedOptions}.
39
+ *
40
+ * @remarks
41
+ * Before adding use of this utility type, consider using a utility like
42
+ * {@link https://github.com/sinclairzx81/typebox#readme | TypeBox} that allows
43
+ * for runtime validation.
44
+ *
45
+ * This filter can be used to derive the expected type of a JSON deserialized
46
+ * value whether or not the type of value serialized meets serialization
47
+ * constraints (see {@link JsonSerializable} including serialization pitfalls).
48
+ *
49
+ * When used as a filter to inferred generic `T`, a compile-time error can be
50
+ * produced trying to assign `JsonDeserialized<T>` to `T`.
51
+ *
52
+ * Simply deserialized JSON never contains `bigint`, `undefined`, `symbol`,
53
+ * or function values. (Object properties which had those types before encoding
54
+ * are omitted during serialization and thus won't be present after
55
+ * deserialization.) Therefore, through this filter, such properties:
56
+ *
57
+ * - become optional with those types excluded (when there are other supported
58
+ * types in union)
59
+ *
60
+ * - are removed (when nothing else in union is supported)
61
+ *
62
+ * - in an array are (1) replaced with `null` if `undefined`, `symbol`, and
63
+ * function values or (2) simply removed (become `never`) if `bigint` value as
64
+ * serialization attempts will throw.
65
+ *
66
+ * Examples results:
67
+ *
68
+ * | Before serialization | After deserialization | After in record | After in array |
69
+ * | --------------------- | --------------------- | ------------------ | --------------------:|
70
+ * | `undefined \| number` | `number` | `prop?: number` | `(number \| null)[]` |
71
+ * | `symbol \| number` | `number` | `prop?: number` | `(number \| null)[]` |
72
+ * | `bigint \| number` | `number` | `prop: number` | `number[]` |
73
+ * | `undefined` | N/A `never` | (prop not present) | `null[]` |
74
+ * | `symbol` | N/A `never` | (prop not present) | `null[]` |
75
+ * | `bigint` | N/A `never` | N/A (prop not present) | N/A `never[]` |
76
+ * | `bigint \| symbol` | N/A `never` | (prop not present) | `null[]` |
77
+ * | `bigint \| number \| symbol` | `number` | `prop?: number` | `(number \| null)[]` |
78
+ *
79
+ * Setter and getter properties become value properties after filtering
80
+ * although no data will be persisted assuming those properties are backed
81
+ * by functions. If an implementation of getter/setter interface uses a
82
+ * simple data member (of supported type), that will persist.
83
+ *
84
+ * Recursive types without any required modification are preserved intact.
85
+ * Recursive types that require modification are unrolled a limited number of
86
+ * times (currently 4) and then further instances of recursion are replaced with
87
+ * {@link JsonTypeWith|JsonTypeWith<Options.AllowExactly "or" Options.AllowExtensionOf>}.
88
+ *
89
+ * Under basic serialization, class instances become simple data objects that
90
+ * lose hidden properties and prototypes that are required for `instanceof`
91
+ * runtime checks.
92
+ *
93
+ * The optional 'Options.AllowExactly' and 'Options.AllowExtensionOf'
94
+ * parameters may be used to permit additional leaf types handled by custom
95
+ * serialization/deserialization logic.
96
+ *
97
+ * @example Example usage
98
+ *
99
+ * ```typescript
100
+ * function foo<T>(): JsonDeserialized<T> { ... }
101
+ * ```
102
+ *
103
+ * @alpha
104
+ */
105
+ export type JsonDeserialized<T, Options extends JsonDeserializedOptions = {
106
+ AllowExactly: never;
107
+ AllowExtensionOf: never;
108
+ }> = InternalUtilityTypes.JsonDeserializedImpl<T, Options>;
109
+ //# sourceMappingURL=jsonDeserialized.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonDeserialized.d.ts","sourceRoot":"","sources":["../../src/core-interfaces/jsonDeserialized.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAErE;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACvC;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;;;;;OAOG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AACH,MAAM,MAAM,gBAAgB,CAC3B,CAAC,EACD,OAAO,SAAS,uBAAuB,GAAG;IACzC,YAAY,EAAE,KAAK,CAAC;IACpB,gBAAgB,EAAE,KAAK,CAAC;CACxB,IACE,oBAAoB,CAAC,oBAAoB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=jsonDeserialized.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonDeserialized.js","sourceRoot":"","sources":["../../src/core-interfaces/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 \"./exposedUtilityTypes.js\";\n\n/**\n * Options for {@link JsonDeserialized}.\n *\n * @alpha\n */\nexport interface JsonDeserializedOptions {\n\t/**\n\t * 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 `never`.\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 \"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.\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 * @alpha\n */\nexport type JsonDeserialized<\n\tT,\n\tOptions extends JsonDeserializedOptions = {\n\t\tAllowExactly: never;\n\t\tAllowExtensionOf: never;\n\t},\n> = InternalUtilityTypes.JsonDeserializedImpl<T, Options>;\n"]}
@@ -0,0 +1,120 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { InternalUtilityTypes } from "./exposedUtilityTypes.js";
6
+ /**
7
+ * Options for {@link JsonSerializable}.
8
+ *
9
+ * @alpha
10
+ */
11
+ export interface JsonSerializableOptions {
12
+ /**
13
+ * Exact types that are managed by custom serialization logic (beyond
14
+ * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify|JSON.stringify}
15
+ * without a replacer). Only exact types matching specification will be
16
+ * preserved unaltered.
17
+ *
18
+ * The default value is `never`.
19
+ */
20
+ AllowExactly?: unknown;
21
+ /**
22
+ * General types that are managed by custom serialization logic (beyond
23
+ * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify|JSON.stringify}
24
+ * without a replacer). Any type satisfying specification will be preserved
25
+ * unaltered.
26
+ *
27
+ * The default value is `never`.
28
+ */
29
+ AllowExtensionOf?: unknown;
30
+ /**
31
+ * When set, inaccessible (protected and private) members throughout type T are
32
+ * ignored as if not present.
33
+ *
34
+ * The default value is not present.
35
+ */
36
+ IgnoreInaccessibleMembers?: "ignore-inaccessible-members";
37
+ }
38
+ /**
39
+ * Used to constrain a type `T` to types that are serializable as JSON
40
+ * using {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify|JSON.stringify}
41
+ * (without a replacer) as base model.
42
+ *
43
+ * Under typical use a compile-time error is produced if `T` contains
44
+ * non-JsonSerializable members.
45
+ *
46
+ * @typeParam T - The type to be constrained.
47
+ * @typeParam Options - Options for the filter. See {@link JsonSerializableOptions}.
48
+ *
49
+ * @remarks
50
+ * Before adding use of this utility type, consider using a utility like
51
+ * {@link https://github.com/sinclairzx81/typebox#readme | TypeBox} that allows
52
+ * for runtime validation.
53
+ *
54
+ * Note that this does NOT prevent use of values with non-JSON compatible data,
55
+ * it only prevents using values with types that include non-JSON compatible data.
56
+ * This means that one can, for example, pass in a value typed with JSON compatible
57
+ * interface into this filter, that could actually be a class with lots on non-JSON
58
+ * compatible fields and methods.
59
+ *
60
+ * Important: `T extends JsonSerializable<T>` is incorrect (does not even compile).
61
+ *
62
+ * The optional `Options.Allow*` parameters may be used to permit additional leaf types
63
+ * to support situations where a `replacer` is used to handle special values (e.g.,
64
+ * `JsonSerializable<{ x: IFluidHandle }, { AllowExtensionOf: IFluidHandle }>`).
65
+ *
66
+ * Note that `JsonSerializable<T>` does not protect against the following pitfalls
67
+ * when serializing with JSON.stringify():
68
+ *
69
+ * - Non-finite numbers (`NaN`, `+/-Infinity`) are coerced to `null`.
70
+ *
71
+ * - Prototypes and non-enumerable properties are lost.
72
+ *
73
+ * - `ArrayLike` types that are not arrays and are serialized as `{ length: number }`.
74
+ *
75
+ * - Getter and setters properties are lost. (Though appear supported.)
76
+ *
77
+ * - Functions with properties may be absent or the properties may be perserved
78
+ * depending on the runtime typo of the value. (If built via Object.assign the
79
+ * target member's type is preserved.) typeof =\> 'function' is lost whereas when
80
+ * typeof =\> 'object' the properties are preserved.
81
+ *
82
+ * - Sparse arrays are filled with `null`.
83
+ *
84
+ * Also, `JsonSerializable<T>` does not prevent the construction of circular references.
85
+ *
86
+ * Specifying `JsonSerializable<unknown>` or `JsonSerializable<any>` yields a type
87
+ * alias for {@link JsonTypeWith}`<never>` and should not be used if precise type
88
+ * safety is desired.
89
+ *
90
+ * Class instances are indistinguishable from general objects by type checking
91
+ * unless they have non-public members.
92
+ * Unless `Option.IgnoreInaccessibleMembers` is used, types with non-public
93
+ * members will result in {@link SerializationErrorPerNonPublicProperties}.
94
+ * When `Option.IgnoreInaccessibleMembers` is `ignore-inaccessible-members`,
95
+ * non-public (non-function) members are preserved without error, but they are
96
+ * filtered away by the type filters and thus produce an incorrectly narrowed
97
+ * type compared to actual data. Though such a result may be customer desired.
98
+ *
99
+ * Perhaps a https://github.com/microsoft/TypeScript/issues/22677 fix will
100
+ * enable better support.
101
+ *
102
+ * @example Typical usage
103
+ *
104
+ * ```typescript
105
+ * function foo<T>(value: JsonSerializable<T>) { ... }
106
+ * ```
107
+ *
108
+ * @privateRemarks
109
+ * Upon recursion, the original type T is preserved intact. This is done to prevent
110
+ * infinite recursion and produces a technically incorrect result type. However, with
111
+ * proper use, that will never be an issue as any filtering of types will happen
112
+ * before T recursion.
113
+ *
114
+ * @alpha
115
+ */
116
+ export type JsonSerializable<T, Options extends JsonSerializableOptions = {
117
+ AllowExactly: never;
118
+ AllowExtensionOf: never;
119
+ }> = InternalUtilityTypes.JsonSerializableImpl<T, Options>;
120
+ //# sourceMappingURL=jsonSerializable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonSerializable.d.ts","sourceRoot":"","sources":["../../src/core-interfaces/jsonSerializable.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAErE;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACvC;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;;;;;OAOG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B;;;;;OAKG;IACH,yBAAyB,CAAC,EAAE,6BAA6B,CAAC;CAC1D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6EG;AACH,MAAM,MAAM,gBAAgB,CAC3B,CAAC,EACD,OAAO,SAAS,uBAAuB,GAAG;IACzC,YAAY,EAAE,KAAK,CAAC;IACpB,gBAAgB,EAAE,KAAK,CAAC;CACxB,IACE,oBAAoB,CAAC,oBAAoB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=jsonSerializable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonSerializable.js","sourceRoot":"","sources":["../../src/core-interfaces/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 \"./exposedUtilityTypes.js\";\n\n/**\n * Options for {@link JsonSerializable}.\n *\n * @alpha\n */\nexport interface JsonSerializableOptions {\n\t/**\n\t * 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 `never`.\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.\n\t *\n\t * The default value is not present.\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 perserved\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>` and should not be used if precise type\n * safety is desired.\n *\n * Class instances are indistinguishable from general objects by type checking\n * unless they have non-public members.\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 * 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 * @alpha\n */\nexport type JsonSerializable<\n\tT,\n\tOptions extends JsonSerializableOptions = {\n\t\tAllowExactly: never;\n\t\tAllowExtensionOf: never;\n\t},\n> = InternalUtilityTypes.JsonSerializableImpl<T, Options>;\n"]}
@@ -0,0 +1,31 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ /**
6
+ * Type resulting from {@link JsonSerializable} use given an array with
7
+ * `undefined` elements.
8
+ *
9
+ * @privateRemarks type is used over interface; so inspection of type
10
+ * result can be more informative than just the type name.
11
+ *
12
+ * @alpha
13
+ * @system
14
+ */
15
+ export type SerializationErrorPerUndefinedArrayElement = {
16
+ "array serialization error": "undefined elements are not supported";
17
+ };
18
+ /**
19
+ * Type resulting from {@link JsonSerializable} use given a class with
20
+ * non-public properties.
21
+ *
22
+ * @privateRemarks type is used over interface; so inspection of type
23
+ * result can be more informative than just the type name.
24
+ *
25
+ * @alpha
26
+ * @system
27
+ */
28
+ export type SerializationErrorPerNonPublicProperties = {
29
+ "object serialization error": "non-public properties are not supported";
30
+ };
31
+ //# sourceMappingURL=jsonSerializationErrors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonSerializationErrors.d.ts","sourceRoot":"","sources":["../../src/core-interfaces/jsonSerializationErrors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;GASG;AAEH,MAAM,MAAM,0CAA0C,GAAG;IACxD,2BAA2B,EAAE,sCAAsC,CAAC;CACpE,CAAC;AAEF;;;;;;;;;GASG;AAEH,MAAM,MAAM,wCAAwC,GAAG;IACtD,4BAA4B,EAAE,yCAAyC,CAAC;CACxE,CAAC"}
@@ -0,0 +1,6 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=jsonSerializationErrors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonSerializationErrors.js","sourceRoot":"","sources":["../../src/core-interfaces/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 * @alpha\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 * @alpha\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"]}
@@ -0,0 +1,29 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ /**
6
+ * Type constraint for types that are likely encodable as JSON, deserializable from JSON,
7
+ * or have a custom alternate type.
8
+ *
9
+ * @remarks
10
+ * Use `JsonTypeWith<never>` for just JSON encodable/deserializable types.
11
+ * See {@link JsonSerializable} for encoding pitfalls.
12
+ *
13
+ * @privateRemarks
14
+ * Prefer using `JsonSerializable<unknown>` or `JsonDeserialized<unknown>` over this type that
15
+ * is an implementation detail.
16
+ * @alpha
17
+ */
18
+ export type JsonTypeWith<T> = null | boolean | number | string | T | {
19
+ [key: string | number]: JsonTypeWith<T>;
20
+ } | JsonTypeWith<T>[];
21
+ /**
22
+ * Portion of {@link JsonTypeWith} that is an object (including array) and not null.
23
+ *
24
+ * @alpha
25
+ */
26
+ export type NonNullJsonObjectWith<T> = {
27
+ [key: string | number]: JsonTypeWith<T>;
28
+ } | JsonTypeWith<T>[];
29
+ //# sourceMappingURL=jsonType.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonType.d.ts","sourceRoot":"","sources":["../../src/core-interfaces/jsonType.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAEvB,IAAI,GACJ,OAAO,GACP,MAAM,GACN,MAAM,GACN,CAAC,GACD;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC,CAAA;CAAE,GAC3C,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;AAErB;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,CAAC,CAAC,IAChC;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC,CAAA;CAAE,GAC3C,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC"}
@@ -0,0 +1,6 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=jsonType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonType.js","sourceRoot":"","sources":["../../src/core-interfaces/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 * @alpha\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 * @alpha\n */\nexport type NonNullJsonObjectWith<T> =\n\t| { [key: string | number]: JsonTypeWith<T> }\n\t| JsonTypeWith<T>[];\n"]}
@@ -0,0 +1,48 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { IFluidLoadable } from "@fluidframework/core-interfaces";
6
+ import type { SharedObjectKind } from "@fluidframework/shared-object-base";
7
+ import type { IPresence } from "./presence.js";
8
+ /**
9
+ * Brand for Experimental Presence Data Object.
10
+ *
11
+ * @remarks
12
+ * See {@link acquirePresenceViaDataObject} for example usage.
13
+ *
14
+ * @sealed
15
+ * @alpha
16
+ */
17
+ export declare class ExperimentalPresenceDO {
18
+ private readonly _self;
19
+ }
20
+ /**
21
+ * DataStore based Presence Manager that is used as fallback for preferred Container
22
+ * Extension based version requires registration. Export SharedObjectKind for registration.
23
+ *
24
+ * @alpha
25
+ */
26
+ export declare const ExperimentalPresenceManager: SharedObjectKind<IFluidLoadable & ExperimentalPresenceDO>;
27
+ /**
28
+ * Acquire IPresence from a DataStore based Presence Manager
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * const containerSchema = {
33
+ * initialObjects: {
34
+ * experimentalPresence: ExperimentalPresenceDO,
35
+ * },
36
+ * } satisfies ContainerSchema;
37
+ * ```
38
+ * then
39
+ * ```typescript
40
+ * const presence = acquirePresenceViaDataObject(
41
+ * container.initialObjects.experimentalPresence,
42
+ * );
43
+ * ```
44
+ *
45
+ * @alpha
46
+ */
47
+ export declare function acquirePresenceViaDataObject(fluidLoadable: ExperimentalPresenceDO): IPresence;
48
+ //# sourceMappingURL=datastorePresenceManagerFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"datastorePresenceManagerFactory.d.ts","sourceRoot":"","sources":["../src/datastorePresenceManagerFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAGtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAG3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAkD/C;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,OAAO,sBAAsB;IAC1C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAyB;CAC/C;AAED;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,2DAGtC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,4BAA4B,CAC3C,aAAa,EAAE,sBAAsB,GACnC,SAAS,CAMX"}
@@ -0,0 +1,75 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { assert } from "@fluidframework/core-utils/internal";
6
+ import { BasicDataStoreFactory, LoadableFluidObject } from "./datastoreSupport.js";
7
+ import { createPresenceManager } from "./presenceManager.js";
8
+ function assertSignalMessageIsValid(message) {
9
+ assert(message.clientId !== null, 0xa58 /* Signal must have a client ID */);
10
+ // The other difference between messages is that `content` for
11
+ // IExtensionMessage is JsonDeserialized and we are fine assuming that.
12
+ }
13
+ /**
14
+ * Simple FluidObject holding Presence Manager.
15
+ */
16
+ class PresenceManagerDataObject extends LoadableFluidObject {
17
+ presenceManager() {
18
+ if (!this._presenceManager) {
19
+ // TODO: investigate if ContainerExtensionStore (path-based address routing for
20
+ // Signals) is readily detectable here and use that presence manager directly.
21
+ const manager = createPresenceManager(this.runtime);
22
+ this.runtime.on("signal", (message, local) => {
23
+ assertSignalMessageIsValid(message);
24
+ manager.processSignal("", message, local);
25
+ });
26
+ this._presenceManager = manager;
27
+ }
28
+ return this._presenceManager;
29
+ }
30
+ }
31
+ /**
32
+ * Factory class to create {@link IPresence} in own data store.
33
+ */
34
+ class PresenceManagerFactory {
35
+ constructor() {
36
+ this.factory = new BasicDataStoreFactory("@fluidframework/presence", PresenceManagerDataObject);
37
+ }
38
+ is(value) {
39
+ return value instanceof PresenceManagerDataObject;
40
+ }
41
+ }
42
+ /**
43
+ * DataStore based Presence Manager that is used as fallback for preferred Container
44
+ * Extension based version requires registration. Export SharedObjectKind for registration.
45
+ *
46
+ * @alpha
47
+ */
48
+ export const ExperimentalPresenceManager = new PresenceManagerFactory();
49
+ /**
50
+ * Acquire IPresence from a DataStore based Presence Manager
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * const containerSchema = {
55
+ * initialObjects: {
56
+ * experimentalPresence: ExperimentalPresenceDO,
57
+ * },
58
+ * } satisfies ContainerSchema;
59
+ * ```
60
+ * then
61
+ * ```typescript
62
+ * const presence = acquirePresenceViaDataObject(
63
+ * container.initialObjects.experimentalPresence,
64
+ * );
65
+ * ```
66
+ *
67
+ * @alpha
68
+ */
69
+ export function acquirePresenceViaDataObject(fluidLoadable) {
70
+ if (fluidLoadable instanceof PresenceManagerDataObject) {
71
+ return fluidLoadable.presenceManager();
72
+ }
73
+ throw new Error("Incompatible loadable; make sure to use ExperimentalPresenceManager");
74
+ }
75
+ //# sourceMappingURL=datastorePresenceManagerFactory.js.map