@liveblocks/core 1.4.7-test1 → 1.4.8-test1

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.mts CHANGED
@@ -1825,7 +1825,6 @@ declare type ClientOptions = {
1825
1825
  lostConnectionTimeout?: number;
1826
1826
  polyfills?: Polyfills;
1827
1827
  unstable_fallbackToHTTP?: boolean;
1828
- unstable_streamData?: boolean;
1829
1828
  /**
1830
1829
  * @deprecated Use `polyfills: { fetch: ... }` instead.
1831
1830
  * This option will be removed in a future release.
package/dist/index.d.ts CHANGED
@@ -1825,7 +1825,6 @@ declare type ClientOptions = {
1825
1825
  lostConnectionTimeout?: number;
1826
1826
  polyfills?: Polyfills;
1827
1827
  unstable_fallbackToHTTP?: boolean;
1828
- unstable_streamData?: boolean;
1829
1828
  /**
1830
1829
  * @deprecated Use `polyfills: { fetch: ... }` instead.
1831
1830
  * This option will be removed in a future release.
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 = "1.4.7-test1";
9
+ var PKG_VERSION = "1.4.8-test1";
10
10
  var PKG_FORMAT = "cjs";
11
11
 
12
12
  // src/dupe-detection.ts
@@ -4900,23 +4900,6 @@ function createRoom(options, config) {
4900
4900
  ydoc: makeEventSource(),
4901
4901
  comments: makeEventSource()
4902
4902
  };
4903
- async function streamFetch(authTokenOrPublicApiKey, roomId) {
4904
- const baseUrl = new URL(config.liveblocksServer);
4905
- baseUrl.protocol = "https";
4906
- const url = new URL(
4907
- `/v2/c/rooms/${encodeURIComponent(roomId)}/storage`,
4908
- baseUrl
4909
- );
4910
- const fetcher = _optionalChain([config, 'access', _115 => _115.polyfills, 'optionalAccess', _116 => _116.fetch]) || /* istanbul ignore next */
4911
- fetch;
4912
- return fetcher(url.toString(), {
4913
- method: "GET",
4914
- headers: {
4915
- "Content-Type": "application/json",
4916
- Authorization: `Bearer ${authTokenOrPublicApiKey}`
4917
- }
4918
- });
4919
- }
4920
4903
  async function httpSend(authTokenOrPublicApiKey, roomId, nonce, messages) {
4921
4904
  const baseUrl = new URL(config.liveblocksServer);
4922
4905
  baseUrl.protocol = "https";
@@ -4924,7 +4907,7 @@ function createRoom(options, config) {
4924
4907
  `/v2/c/rooms/${encodeURIComponent(roomId)}/send-message`,
4925
4908
  baseUrl
4926
4909
  );
4927
- const fetcher = _optionalChain([config, 'access', _117 => _117.polyfills, 'optionalAccess', _118 => _118.fetch]) || /* istanbul ignore next */
4910
+ const fetcher = _optionalChain([config, 'access', _115 => _115.polyfills, 'optionalAccess', _116 => _116.fetch]) || /* istanbul ignore next */
4928
4911
  fetch;
4929
4912
  return fetcher(url.toString(), {
4930
4913
  method: "POST",
@@ -4937,7 +4920,7 @@ function createRoom(options, config) {
4937
4920
  }
4938
4921
  function sendMessages(messages) {
4939
4922
  const serializedPayload = JSON.stringify(messages);
4940
- const nonce = _optionalChain([context, 'access', _119 => _119.dynamicSessionInfo, 'access', _120 => _120.current, 'optionalAccess', _121 => _121.nonce]);
4923
+ const nonce = _optionalChain([context, 'access', _117 => _117.dynamicSessionInfo, 'access', _118 => _118.current, 'optionalAccess', _119 => _119.nonce]);
4941
4924
  if (config.unstable_fallbackToHTTP && managedSocket.authValue && nonce) {
4942
4925
  const size = new TextEncoder().encode(serializedPayload).length;
4943
4926
  if (size > MAX_SOCKET_MESSAGE_SIZE) {
@@ -5204,7 +5187,7 @@ function createRoom(options, config) {
5204
5187
  }
5205
5188
  context.myPresence.patch(patch);
5206
5189
  if (context.activeBatch) {
5207
- if (_optionalChain([options2, 'optionalAccess', _122 => _122.addToHistory])) {
5190
+ if (_optionalChain([options2, 'optionalAccess', _120 => _120.addToHistory])) {
5208
5191
  context.activeBatch.reverseOps.unshift({
5209
5192
  type: "presence",
5210
5193
  data: oldValues
@@ -5214,7 +5197,7 @@ function createRoom(options, config) {
5214
5197
  } else {
5215
5198
  flushNowOrSoon();
5216
5199
  batchUpdates(() => {
5217
- if (_optionalChain([options2, 'optionalAccess', _123 => _123.addToHistory])) {
5200
+ if (_optionalChain([options2, 'optionalAccess', _121 => _121.addToHistory])) {
5218
5201
  addToUndoStack(
5219
5202
  [{ type: "presence", data: oldValues }],
5220
5203
  doNotBatchUpdates
@@ -5391,7 +5374,12 @@ function createRoom(options, config) {
5391
5374
  break;
5392
5375
  }
5393
5376
  case 200 /* INITIAL_STORAGE_STATE */: {
5394
- processInitialStorage(message);
5377
+ const unacknowledgedOps = new Map(context.unacknowledgedOps);
5378
+ createOrUpdateRootFromMessage(message, doNotBatchUpdates);
5379
+ applyAndSendOps(unacknowledgedOps, doNotBatchUpdates);
5380
+ _optionalChain([_resolveStoragePromise, 'optionalCall', _122 => _122()]);
5381
+ notifyStorageStatus();
5382
+ eventHub.storageDidLoad.notify();
5395
5383
  break;
5396
5384
  }
5397
5385
  case 201 /* UPDATE_STORAGE */: {
@@ -5412,7 +5400,7 @@ function createRoom(options, config) {
5412
5400
  if (process.env.NODE_ENV !== "production") {
5413
5401
  const traces = /* @__PURE__ */ new Set();
5414
5402
  for (const opId of message.opIds) {
5415
- const trace = _optionalChain([context, 'access', _124 => _124.opStackTraces, 'optionalAccess', _125 => _125.get, 'call', _126 => _126(opId)]);
5403
+ const trace = _optionalChain([context, 'access', _123 => _123.opStackTraces, 'optionalAccess', _124 => _124.get, 'call', _125 => _125(opId)]);
5416
5404
  if (trace) {
5417
5405
  traces.add(trace);
5418
5406
  }
@@ -5536,30 +5524,9 @@ ${Array.from(traces).join("\n\n")}`
5536
5524
  }
5537
5525
  let _getStorage$ = null;
5538
5526
  let _resolveStoragePromise = null;
5539
- function processInitialStorage(message) {
5540
- const unacknowledgedOps = new Map(context.unacknowledgedOps);
5541
- createOrUpdateRootFromMessage(message, doNotBatchUpdates);
5542
- applyAndSendOps(unacknowledgedOps, doNotBatchUpdates);
5543
- _optionalChain([_resolveStoragePromise, 'optionalCall', _127 => _127()]);
5544
- notifyStorageStatus();
5545
- eventHub.storageDidLoad.notify();
5546
- }
5547
- async function streamStorage() {
5548
- if (!managedSocket.authValue) {
5549
- return;
5550
- }
5551
- const result = await streamFetch(
5552
- managedSocket.authValue.type === "public" ? managedSocket.authValue.publicApiKey : managedSocket.authValue.token.raw,
5553
- config.roomId
5554
- );
5555
- const items = await result.json();
5556
- processInitialStorage({ type: 200 /* INITIAL_STORAGE_STATE */, items });
5557
- }
5558
5527
  function refreshStorage(options2) {
5559
5528
  const messages = context.buffer.messages;
5560
- if (config.unstable_streamData) {
5561
- void streamStorage();
5562
- } else if (!messages.some((msg) => msg.type === 200 /* FETCH_STORAGE */)) {
5529
+ if (!messages.some((msg) => msg.type === 200 /* FETCH_STORAGE */)) {
5563
5530
  messages.push({ type: 200 /* FETCH_STORAGE */ });
5564
5531
  }
5565
5532
  if (options2.flush) {
@@ -5745,7 +5712,7 @@ ${Array.from(traces).join("\n\n")}`
5745
5712
  /* NOTE: Exposing __internal here only to allow testing implementation details in unit tests */
5746
5713
  __internal: {
5747
5714
  get presenceBuffer() {
5748
- return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _128 => _128.buffer, 'access', _129 => _129.presenceUpdates, 'optionalAccess', _130 => _130.data]), () => ( null)));
5715
+ return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _126 => _126.buffer, 'access', _127 => _127.presenceUpdates, 'optionalAccess', _128 => _128.data]), () => ( null)));
5749
5716
  },
5750
5717
  // prettier-ignore
5751
5718
  get undoStack() {
@@ -5881,7 +5848,7 @@ function makeClassicSubscribeFn(events) {
5881
5848
  }
5882
5849
  if (isLiveNode(first)) {
5883
5850
  const node = first;
5884
- if (_optionalChain([options, 'optionalAccess', _131 => _131.isDeep])) {
5851
+ if (_optionalChain([options, 'optionalAccess', _129 => _129.isDeep])) {
5885
5852
  const storageCallback = second;
5886
5853
  return subscribeToLiveStructureDeeply(node, storageCallback);
5887
5854
  } else {
@@ -5972,15 +5939,14 @@ function createClient(options) {
5972
5939
  createSocket: makeCreateSocketDelegateForRoom(
5973
5940
  roomId,
5974
5941
  getServerFromClientOptions(clientOptions),
5975
- _optionalChain([clientOptions, 'access', _132 => _132.polyfills, 'optionalAccess', _133 => _133.WebSocket])
5942
+ _optionalChain([clientOptions, 'access', _130 => _130.polyfills, 'optionalAccess', _131 => _131.WebSocket])
5976
5943
  ),
5977
5944
  authenticate: makeAuthDelegateForRoom(roomId, authManager)
5978
5945
  })),
5979
5946
  enableDebugLogging: clientOptions.enableDebugLogging,
5980
- unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess', _134 => _134.unstable_batchedUpdates]),
5947
+ unstable_batchedUpdates: _optionalChain([options2, 'optionalAccess', _132 => _132.unstable_batchedUpdates]),
5981
5948
  liveblocksServer: getServerFromClientOptions(clientOptions),
5982
- unstable_fallbackToHTTP: !!clientOptions.unstable_fallbackToHTTP,
5983
- unstable_streamData: !!clientOptions.unstable_streamData
5949
+ unstable_fallbackToHTTP: !!clientOptions.unstable_fallbackToHTTP
5984
5950
  }
5985
5951
  );
5986
5952
  rooms.set(roomId, newRoom);
@@ -5989,7 +5955,7 @@ function createClient(options) {
5989
5955
  const shouldConnect = _nullishCoalesce(options2.shouldInitiallyConnect, () => ( true));
5990
5956
  if (shouldConnect) {
5991
5957
  if (typeof atob === "undefined") {
5992
- if (_optionalChain([clientOptions, 'access', _135 => _135.polyfills, 'optionalAccess', _136 => _136.atob]) === void 0) {
5958
+ if (_optionalChain([clientOptions, 'access', _133 => _133.polyfills, 'optionalAccess', _134 => _134.atob]) === void 0) {
5993
5959
  throw new Error(
5994
5960
  "You need to polyfill atob to use the client in your environment. Please follow the instructions at https://liveblocks.io/docs/errors/liveblocks-client/atob-polyfill"
5995
5961
  );
@@ -6264,12 +6230,12 @@ function legacy_patchImmutableNode(state, path, update) {
6264
6230
  }
6265
6231
  const newState = Object.assign({}, state);
6266
6232
  for (const key in update.updates) {
6267
- if (_optionalChain([update, 'access', _137 => _137.updates, 'access', _138 => _138[key], 'optionalAccess', _139 => _139.type]) === "update") {
6233
+ if (_optionalChain([update, 'access', _135 => _135.updates, 'access', _136 => _136[key], 'optionalAccess', _137 => _137.type]) === "update") {
6268
6234
  const val = update.node.get(key);
6269
6235
  if (val !== void 0) {
6270
6236
  newState[key] = lsonToJson(val);
6271
6237
  }
6272
- } else if (_optionalChain([update, 'access', _140 => _140.updates, 'access', _141 => _141[key], 'optionalAccess', _142 => _142.type]) === "delete") {
6238
+ } else if (_optionalChain([update, 'access', _138 => _138.updates, 'access', _139 => _139[key], 'optionalAccess', _140 => _140.type]) === "delete") {
6273
6239
  delete newState[key];
6274
6240
  }
6275
6241
  }
@@ -6330,12 +6296,12 @@ function legacy_patchImmutableNode(state, path, update) {
6330
6296
  }
6331
6297
  const newState = Object.assign({}, state);
6332
6298
  for (const key in update.updates) {
6333
- if (_optionalChain([update, 'access', _143 => _143.updates, 'access', _144 => _144[key], 'optionalAccess', _145 => _145.type]) === "update") {
6299
+ if (_optionalChain([update, 'access', _141 => _141.updates, 'access', _142 => _142[key], 'optionalAccess', _143 => _143.type]) === "update") {
6334
6300
  const value = update.node.get(key);
6335
6301
  if (value !== void 0) {
6336
6302
  newState[key] = lsonToJson(value);
6337
6303
  }
6338
- } else if (_optionalChain([update, 'access', _146 => _146.updates, 'access', _147 => _147[key], 'optionalAccess', _148 => _148.type]) === "delete") {
6304
+ } else if (_optionalChain([update, 'access', _144 => _144.updates, 'access', _145 => _145[key], 'optionalAccess', _146 => _146.type]) === "delete") {
6339
6305
  delete newState[key];
6340
6306
  }
6341
6307
  }
@@ -6425,7 +6391,7 @@ function createCacheItem(key, asyncFunction, options) {
6425
6391
  let previousState = { isLoading: false };
6426
6392
  const eventSource2 = makeEventSource();
6427
6393
  function notify() {
6428
- const isEqual = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _149 => _149.isStateEqual]), () => ( isShallowEqual));
6394
+ const isEqual = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _147 => _147.isStateEqual]), () => ( isShallowEqual));
6429
6395
  if (!isEqual(previousState, state)) {
6430
6396
  previousState = state;
6431
6397
  eventSource2.notify(state);
@@ -6493,7 +6459,7 @@ function createAsyncCache(asyncFunction, options) {
6493
6459
  return create(key).get();
6494
6460
  }
6495
6461
  function getState(key) {
6496
- return _optionalChain([cache, 'access', _150 => _150.get, 'call', _151 => _151(key), 'optionalAccess', _152 => _152.getState, 'call', _153 => _153()]);
6462
+ return _optionalChain([cache, 'access', _148 => _148.get, 'call', _149 => _149(key), 'optionalAccess', _150 => _150.getState, 'call', _151 => _151()]);
6497
6463
  }
6498
6464
  function revalidate(key) {
6499
6465
  return create(key).revalidate();