@liveblocks/core 3.24.0 → 3.24.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1253,6 +1253,24 @@ type LiveNode = LiveStructure | LiveRegister<Json>;
1253
1253
  * value or a Live storage data structure (LiveMap, LiveList, etc.)
1254
1254
  */
1255
1255
  type LsonObject = Record<string, Lson | undefined>;
1256
+ /**
1257
+ * The Json object an Lson object serializes to: every value converted with
1258
+ * `ToJson`, optional keys staying optional.
1259
+ */
1260
+ type JsonObjectOf<O extends LsonObject> = {
1261
+ readonly [K in keyof O]: ToJson<Exclude<O[K], undefined>> | (undefined extends O[K] ? undefined : never);
1262
+ };
1263
+ /**
1264
+ * The Json value a plain Lson object serializes to: an opaque record collapses
1265
+ * to ReadonlyJsonObject, anything else is mapped key by key.
1266
+ *
1267
+ * Inferring V keeps this conditional resolvable, which ToJson's variance
1268
+ * depends on. Deferring it makes unrelated assignments fail, such as
1269
+ * LiveList<never> to Lson.
1270
+ */
1271
+ type JsonOfLsonObject<L extends LsonObject> = string extends keyof L ? L extends Record<string, infer V> ? Record<string, V> extends L ? [
1272
+ Json
1273
+ ] extends [V] ? ReadonlyJsonObject : JsonObjectOf<L> : JsonObjectOf<L> : JsonObjectOf<L> : JsonObjectOf<L>;
1256
1274
  /**
1257
1275
  * Helper type to convert any valid Lson type to the equivalent Json type.
1258
1276
  *
@@ -1268,13 +1286,9 @@ type LsonObject = Record<string, Lson | undefined>;
1268
1286
  * ToJson<LiveObject<{ a: number, b: LiveList<string>, c?: number }>>
1269
1287
  * // { readonly a: null, readonly b: readonly string[], readonly c?: number }
1270
1288
  */
1271
- type ToJson<L extends Lson | LsonObject> = L extends LiveList<infer I extends Lson> ? Lson extends I ? readonly ReadonlyJson[] : readonly ToJson<I>[] : L extends LiveObject<infer O extends LsonObject> ? LsonObject extends O ? ReadonlyJsonObject : {
1272
- readonly [K in keyof O]: ToJson<Exclude<O[K], undefined>> | (undefined extends O[K] ? undefined : never);
1273
- } : L extends LiveMap<infer KS extends string, infer V extends Lson> ? Lson extends V ? ReadonlyJsonObject : {
1289
+ type ToJson<L extends Lson | LsonObject> = L extends LiveList<infer I extends Lson> ? Lson extends I ? readonly ReadonlyJson[] : readonly ToJson<I>[] : L extends LiveObject<infer O extends LsonObject> ? JsonOfLsonObject<O> : L extends LiveMap<infer KS extends string, infer V extends Lson> ? Lson extends V ? ReadonlyJsonObject : {
1274
1290
  readonly [K in KS]: ToJson<V>;
1275
- } : L extends LiveText ? LiveTextData : L extends LiveFile ? LiveFileData : L extends LsonObject ? string extends keyof L ? ReadonlyJsonObject : {
1276
- readonly [K in keyof L]: ToJson<Exclude<L[K], undefined>> | (undefined extends L[K] ? undefined : never);
1277
- } : L extends Json ? L : never;
1291
+ } : L extends LiveText ? LiveTextData : L extends LiveFile ? LiveFileData : L extends LsonObject ? JsonOfLsonObject<L> : L extends Json ? L : never;
1278
1292
 
1279
1293
  /**
1280
1294
  * Read-only query surface over {@link UnacknowledgedOps}, handed to CRDTs so
@@ -1890,7 +1904,7 @@ type NotificationChannelSettings = {
1890
1904
  * Base definition of notification settings.
1891
1905
  * Plain means it's a simple object coming from the remote backend.
1892
1906
  *
1893
- * It's the raw settings object where somme channels cannot exists
1907
+ * It's the raw settings object where some channels cannot exists
1894
1908
  * because there are no notification kinds enabled on the dashboard.
1895
1909
  * And this object isn't yet proxied by the creator factory `createNotificationSettings`.
1896
1910
  */
package/dist/index.d.ts CHANGED
@@ -1253,6 +1253,24 @@ type LiveNode = LiveStructure | LiveRegister<Json>;
1253
1253
  * value or a Live storage data structure (LiveMap, LiveList, etc.)
1254
1254
  */
1255
1255
  type LsonObject = Record<string, Lson | undefined>;
1256
+ /**
1257
+ * The Json object an Lson object serializes to: every value converted with
1258
+ * `ToJson`, optional keys staying optional.
1259
+ */
1260
+ type JsonObjectOf<O extends LsonObject> = {
1261
+ readonly [K in keyof O]: ToJson<Exclude<O[K], undefined>> | (undefined extends O[K] ? undefined : never);
1262
+ };
1263
+ /**
1264
+ * The Json value a plain Lson object serializes to: an opaque record collapses
1265
+ * to ReadonlyJsonObject, anything else is mapped key by key.
1266
+ *
1267
+ * Inferring V keeps this conditional resolvable, which ToJson's variance
1268
+ * depends on. Deferring it makes unrelated assignments fail, such as
1269
+ * LiveList<never> to Lson.
1270
+ */
1271
+ type JsonOfLsonObject<L extends LsonObject> = string extends keyof L ? L extends Record<string, infer V> ? Record<string, V> extends L ? [
1272
+ Json
1273
+ ] extends [V] ? ReadonlyJsonObject : JsonObjectOf<L> : JsonObjectOf<L> : JsonObjectOf<L> : JsonObjectOf<L>;
1256
1274
  /**
1257
1275
  * Helper type to convert any valid Lson type to the equivalent Json type.
1258
1276
  *
@@ -1268,13 +1286,9 @@ type LsonObject = Record<string, Lson | undefined>;
1268
1286
  * ToJson<LiveObject<{ a: number, b: LiveList<string>, c?: number }>>
1269
1287
  * // { readonly a: null, readonly b: readonly string[], readonly c?: number }
1270
1288
  */
1271
- type ToJson<L extends Lson | LsonObject> = L extends LiveList<infer I extends Lson> ? Lson extends I ? readonly ReadonlyJson[] : readonly ToJson<I>[] : L extends LiveObject<infer O extends LsonObject> ? LsonObject extends O ? ReadonlyJsonObject : {
1272
- readonly [K in keyof O]: ToJson<Exclude<O[K], undefined>> | (undefined extends O[K] ? undefined : never);
1273
- } : L extends LiveMap<infer KS extends string, infer V extends Lson> ? Lson extends V ? ReadonlyJsonObject : {
1289
+ type ToJson<L extends Lson | LsonObject> = L extends LiveList<infer I extends Lson> ? Lson extends I ? readonly ReadonlyJson[] : readonly ToJson<I>[] : L extends LiveObject<infer O extends LsonObject> ? JsonOfLsonObject<O> : L extends LiveMap<infer KS extends string, infer V extends Lson> ? Lson extends V ? ReadonlyJsonObject : {
1274
1290
  readonly [K in KS]: ToJson<V>;
1275
- } : L extends LiveText ? LiveTextData : L extends LiveFile ? LiveFileData : L extends LsonObject ? string extends keyof L ? ReadonlyJsonObject : {
1276
- readonly [K in keyof L]: ToJson<Exclude<L[K], undefined>> | (undefined extends L[K] ? undefined : never);
1277
- } : L extends Json ? L : never;
1291
+ } : L extends LiveText ? LiveTextData : L extends LiveFile ? LiveFileData : L extends LsonObject ? JsonOfLsonObject<L> : L extends Json ? L : never;
1278
1292
 
1279
1293
  /**
1280
1294
  * Read-only query surface over {@link UnacknowledgedOps}, handed to CRDTs so
@@ -1890,7 +1904,7 @@ type NotificationChannelSettings = {
1890
1904
  * Base definition of notification settings.
1891
1905
  * Plain means it's a simple object coming from the remote backend.
1892
1906
  *
1893
- * It's the raw settings object where somme channels cannot exists
1907
+ * It's the raw settings object where some channels cannot exists
1894
1908
  * because there are no notification kinds enabled on the dashboard.
1895
1909
  * And this object isn't yet proxied by the creator factory `createNotificationSettings`.
1896
1910
  */
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ var __export = (target, all) => {
6
6
 
7
7
  // src/version.ts
8
8
  var PKG_NAME = "@liveblocks/core";
9
- var PKG_VERSION = "3.24.0";
9
+ var PKG_VERSION = "3.24.2";
10
10
  var PKG_FORMAT = "esm";
11
11
 
12
12
  // src/dupe-detection.ts
@@ -3628,11 +3628,11 @@ var HttpClient = class {
3628
3628
  const response = await this.#fetchPolyfill(url2, {
3629
3629
  ...options,
3630
3630
  headers: {
3631
- // These headers are default, but can be overriden by custom headers
3631
+ // These headers are default, but can be overridden by custom headers
3632
3632
  "Content-Type": "application/json; charset=utf-8",
3633
3633
  // Possible header overrides
3634
3634
  ...options?.headers,
3635
- // Cannot be overriden by custom headers
3635
+ // Cannot be overridden by custom headers
3636
3636
  Authorization: `Bearer ${getBearerTokenFromAuthValue(authValue)}`,
3637
3637
  "X-LB-Client": PKG_VERSION || "dev"
3638
3638
  }
@@ -3678,7 +3678,7 @@ var HttpClient = class {
3678
3678
  }
3679
3679
  /**
3680
3680
  * Makes a GET request and returns the raw response.
3681
- * Won't throw if the reponse is a non-2xx.
3681
+ * Won't throw if the response is a non-2xx.
3682
3682
  * @deprecated Ideally, use .get() instead.
3683
3683
  */
3684
3684
  async rawGet(endpoint, authValue, params, options) {
@@ -3686,7 +3686,7 @@ var HttpClient = class {
3686
3686
  }
3687
3687
  /**
3688
3688
  * Makes a POST request and returns the raw response.
3689
- * Won't throw if the reponse is a non-2xx.
3689
+ * Won't throw if the response is a non-2xx.
3690
3690
  * @deprecated Ideally, use .post() instead.
3691
3691
  */
3692
3692
  async rawPost(endpoint, authValue, body) {
@@ -3697,7 +3697,7 @@ var HttpClient = class {
3697
3697
  }
3698
3698
  /**
3699
3699
  * Makes a DELETE request and returns the raw response.
3700
- * Won't throw if the reponse is a non-2xx.
3700
+ * Won't throw if the response is a non-2xx.
3701
3701
  * @deprecated Ideally, use .delete() instead.
3702
3702
  */
3703
3703
  async rawDelete(endpoint, authValue) {
@@ -3705,14 +3705,14 @@ var HttpClient = class {
3705
3705
  }
3706
3706
  /**
3707
3707
  * Makes a GET request, and return the JSON response.
3708
- * Will throw if the reponse is a non-2xx.
3708
+ * Will throw if the response is a non-2xx.
3709
3709
  */
3710
3710
  async get(endpoint, authValue, params, options) {
3711
3711
  return await this.#fetch(endpoint, authValue, options, params);
3712
3712
  }
3713
3713
  /**
3714
3714
  * Makes a POST request, and return the JSON response.
3715
- * Will throw if the reponse is a non-2xx.
3715
+ * Will throw if the response is a non-2xx.
3716
3716
  */
3717
3717
  async post(endpoint, authValue, body, options, params) {
3718
3718
  return await this.#fetch(
@@ -3728,14 +3728,14 @@ var HttpClient = class {
3728
3728
  }
3729
3729
  /**
3730
3730
  * Makes a DELETE request, and return the JSON response.
3731
- * Will throw if the reponse is a non-2xx.
3731
+ * Will throw if the response is a non-2xx.
3732
3732
  */
3733
3733
  async delete(endpoint, authValue) {
3734
3734
  return await this.#fetch(endpoint, authValue, { method: "DELETE" });
3735
3735
  }
3736
3736
  /**
3737
3737
  * Makes a PUT request for a Blob body, and return the JSON response.
3738
- * Will throw if the reponse is a non-2xx.
3738
+ * Will throw if the response is a non-2xx.
3739
3739
  */
3740
3740
  async putBlob(endpoint, authValue, blob, params, options) {
3741
3741
  return await this.#fetch(
@@ -13721,7 +13721,7 @@ ${dumpPool(
13721
13721
  updateSubscriptionSettings,
13722
13722
  markInboxNotificationAsRead
13723
13723
  },
13724
- // Explictly make the internal field non-enumerable, to avoid aggressive
13724
+ // Explicitly make the internal field non-enumerable, to avoid aggressive
13725
13725
  // freezing when used with Immer
13726
13726
  kInternal,
13727
13727
  { enumerable: false }