@liveblocks/core 1.1.5-test2 → 1.1.5-test4
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 +1887 -0
- package/dist/index.d.ts +7 -19
- package/dist/index.js +117 -110
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5954 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +14 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Throws an error if multiple copies of a Liveblocks package are being loaded
|
|
3
|
+
* at runtime. This likely indicates a packaging issue with the project.
|
|
4
|
+
*/
|
|
5
|
+
declare function detectDupes(pkgName: string, pkgVersion: string | false, // false if not built yet
|
|
6
|
+
pkgFormat: string | false): void;
|
|
7
|
+
|
|
1
8
|
/**
|
|
2
9
|
* Represents an indefinitely deep arbitrary JSON data structure. There are
|
|
3
10
|
* four types that make up the Json family:
|
|
@@ -1865,25 +1872,6 @@ declare namespace protocol {
|
|
|
1865
1872
|
};
|
|
1866
1873
|
}
|
|
1867
1874
|
|
|
1868
|
-
/**
|
|
1869
|
-
* Throws an error if multiple copies of a Liveblocks package are being loaded
|
|
1870
|
-
* at runtime. This likely indicates a packaging issue with the project.
|
|
1871
|
-
*/
|
|
1872
|
-
declare function detectDupes(pkgName: string, pkgVersion: string, pkgFormat: string): void;
|
|
1873
|
-
|
|
1874
|
-
/**
|
|
1875
|
-
* PRIVATE / INTERNAL APIS
|
|
1876
|
-
* -----------------------
|
|
1877
|
-
*
|
|
1878
|
-
* This module is intended for internal use only, PLEASE DO NOT RELY ON ANY OF
|
|
1879
|
-
* THE EXPORTS IN HERE. These are implementation details that can change at any
|
|
1880
|
-
* time and without announcement. This module purely exists to share code
|
|
1881
|
-
* between the several Liveblocks packages.
|
|
1882
|
-
*
|
|
1883
|
-
* But since you're so deep inside Liveblocks code... we're hiring!
|
|
1884
|
-
* https://join.team/liveblocks ;)
|
|
1885
|
-
*/
|
|
1886
|
-
|
|
1887
1875
|
/**
|
|
1888
1876
|
* Helper type to help users adopt to Lson types from interface definitions.
|
|
1889
1877
|
* You should only use this to wrap interfaces you don't control. For more
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,51 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/version.ts
|
|
2
|
+
var PKG_NAME = "@liveblocks/core";
|
|
3
|
+
var PKG_VERSION = "1.1.5-test4";
|
|
4
|
+
var PKG_FORMAT = "cjs";
|
|
5
|
+
|
|
6
|
+
// src/dupe-detection.ts
|
|
7
|
+
var g = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {};
|
|
8
|
+
var crossLinkedDocs = "https://liveblocks.io/errors/cross-linked";
|
|
9
|
+
var dupesDocs = "https://liveblocks.io/errors/dupes";
|
|
10
|
+
var SPACE = " ";
|
|
11
|
+
function error(msg) {
|
|
12
|
+
if (process.env.NODE_ENV === "production") {
|
|
13
|
+
console.error(msg);
|
|
14
|
+
} else {
|
|
15
|
+
throw new Error(msg);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function detectDupes(pkgName, pkgVersion, pkgFormat) {
|
|
19
|
+
const pkgId = Symbol.for(pkgName);
|
|
20
|
+
const pkgBuildInfo = pkgFormat ? `${pkgVersion || "dev"} (${pkgFormat})` : pkgVersion || "dev";
|
|
21
|
+
if (!g[pkgId]) {
|
|
22
|
+
g[pkgId] = pkgBuildInfo;
|
|
23
|
+
} else {
|
|
24
|
+
const msg = [
|
|
25
|
+
`Multiple copies of Liveblocks are being loaded in your project. This will cause issues! See ${dupesDocs + SPACE}`,
|
|
26
|
+
"",
|
|
27
|
+
"Conflicts:",
|
|
28
|
+
`- ${pkgName} ${g[pkgId]} (already loaded)`,
|
|
29
|
+
`- ${pkgName} ${pkgBuildInfo} (trying to load this now)`
|
|
30
|
+
].join("\n");
|
|
31
|
+
error(msg);
|
|
32
|
+
}
|
|
33
|
+
if (pkgVersion && PKG_VERSION && pkgVersion !== PKG_VERSION) {
|
|
34
|
+
error(
|
|
35
|
+
[
|
|
36
|
+
`Cross-linked versions of Liveblocks found, which will cause issues! See ${crossLinkedDocs + SPACE}`,
|
|
37
|
+
"",
|
|
38
|
+
"Conflicts:",
|
|
39
|
+
`- ${PKG_NAME} is at ${PKG_VERSION}`,
|
|
40
|
+
`- ${pkgName} is at ${pkgVersion}`,
|
|
41
|
+
"",
|
|
42
|
+
"Always upgrade all Liveblocks packages to the same version number."
|
|
43
|
+
].join("\n")
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// src/lib/EventSource.ts
|
|
2
49
|
function makeEventSource() {
|
|
3
50
|
const _onetimeObservers = /* @__PURE__ */ new Set();
|
|
4
51
|
const _observers = /* @__PURE__ */ new Set();
|
|
@@ -101,10 +148,7 @@ if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
|
|
|
101
148
|
var onMessageFromPanel = eventSource.observable;
|
|
102
149
|
|
|
103
150
|
// src/devtools/index.ts
|
|
104
|
-
var VERSION =
|
|
105
|
-
/* istanbul ignore next */
|
|
106
|
-
"1.1.5-test2"
|
|
107
|
-
) : "dev";
|
|
151
|
+
var VERSION = PKG_VERSION || "dev";
|
|
108
152
|
var _devtoolsSetupHasRun = false;
|
|
109
153
|
function setupDevTools(getAllRooms) {
|
|
110
154
|
if (process.env.NODE_ENV === "production" || typeof window === "undefined") {
|
|
@@ -262,7 +306,7 @@ function wrap(method) {
|
|
|
262
306
|
);
|
|
263
307
|
}
|
|
264
308
|
var warn = wrap("warn");
|
|
265
|
-
var
|
|
309
|
+
var error2 = wrap("error");
|
|
266
310
|
function wrapWithTitle(method) {
|
|
267
311
|
return typeof window === "undefined" || process.env.NODE_ENV === "test" ? console[method] : (
|
|
268
312
|
/* istanbul ignore next */
|
|
@@ -836,7 +880,7 @@ function resetSuccessCount(context) {
|
|
|
836
880
|
context.patch({ successCount: 0 });
|
|
837
881
|
}
|
|
838
882
|
function log(level, message) {
|
|
839
|
-
const logger = level === 2 /* ERROR */ ?
|
|
883
|
+
const logger = level === 2 /* ERROR */ ? error2 : level === 1 /* WARN */ ? warn : (
|
|
840
884
|
/* black hole */
|
|
841
885
|
() => {
|
|
842
886
|
}
|
|
@@ -4259,7 +4303,7 @@ function createRoom(options, config) {
|
|
|
4259
4303
|
managedSocket.events.onLiveblocksError.subscribe((err) => {
|
|
4260
4304
|
batchUpdates(() => {
|
|
4261
4305
|
if (process.env.NODE_ENV !== "production") {
|
|
4262
|
-
|
|
4306
|
+
error2(
|
|
4263
4307
|
`Connection to websocket server closed. Reason: ${err.message} (code: ${err.code}).`
|
|
4264
4308
|
);
|
|
4265
4309
|
}
|
|
@@ -5064,65 +5108,71 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
5064
5108
|
storageStatus: eventHub.storageStatus.observable,
|
|
5065
5109
|
ydoc: eventHub.ydoc.observable
|
|
5066
5110
|
};
|
|
5067
|
-
return
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
|
|
5111
|
+
return Object.defineProperty(
|
|
5112
|
+
{
|
|
5113
|
+
/* NOTE: Exposing __internal here only to allow testing implementation details in unit tests */
|
|
5114
|
+
__internal: {
|
|
5115
|
+
get presenceBuffer() {
|
|
5116
|
+
return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _127 => _127.buffer, 'access', _128 => _128.presenceUpdates, 'optionalAccess', _129 => _129.data]), () => ( null)));
|
|
5117
|
+
},
|
|
5118
|
+
// prettier-ignore
|
|
5119
|
+
get undoStack() {
|
|
5120
|
+
return deepClone(context.undoStack);
|
|
5121
|
+
},
|
|
5122
|
+
// prettier-ignore
|
|
5123
|
+
get nodeCount() {
|
|
5124
|
+
return context.nodes.size;
|
|
5125
|
+
},
|
|
5126
|
+
// prettier-ignore
|
|
5127
|
+
// Support for the Liveblocks browser extension
|
|
5128
|
+
getSelf_forDevTools: () => selfAsTreeNode.current,
|
|
5129
|
+
getOthers_forDevTools: () => others_forDevTools.current,
|
|
5130
|
+
// prettier-ignore
|
|
5131
|
+
send: {
|
|
5132
|
+
// These exist only for our E2E testing app
|
|
5133
|
+
explicitClose: (event) => managedSocket._privateSendMachineEvent({ type: "EXPLICIT_SOCKET_CLOSE", event }),
|
|
5134
|
+
implicitClose: () => managedSocket._privateSendMachineEvent({ type: "NAVIGATOR_OFFLINE" })
|
|
5135
|
+
}
|
|
5076
5136
|
},
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5137
|
+
id: config.roomId,
|
|
5138
|
+
subscribe: makeClassicSubscribeFn(events),
|
|
5139
|
+
connect: () => managedSocket.connect(),
|
|
5140
|
+
reconnect: () => managedSocket.reconnect(),
|
|
5141
|
+
disconnect: () => managedSocket.disconnect(),
|
|
5142
|
+
destroy: () => managedSocket.destroy(),
|
|
5143
|
+
// Presence
|
|
5144
|
+
updatePresence,
|
|
5145
|
+
updateYDoc,
|
|
5146
|
+
broadcastEvent,
|
|
5147
|
+
// Storage
|
|
5148
|
+
batch,
|
|
5149
|
+
history: {
|
|
5150
|
+
undo,
|
|
5151
|
+
redo,
|
|
5152
|
+
canUndo,
|
|
5153
|
+
canRedo,
|
|
5154
|
+
pause: pauseHistory,
|
|
5155
|
+
resume: resumeHistory
|
|
5080
5156
|
},
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
connect: () => managedSocket.connect(),
|
|
5095
|
-
reconnect: () => managedSocket.reconnect(),
|
|
5096
|
-
disconnect: () => managedSocket.disconnect(),
|
|
5097
|
-
destroy: () => managedSocket.destroy(),
|
|
5098
|
-
// Presence
|
|
5099
|
-
updatePresence,
|
|
5100
|
-
updateYDoc,
|
|
5101
|
-
broadcastEvent,
|
|
5102
|
-
// Storage
|
|
5103
|
-
batch,
|
|
5104
|
-
history: {
|
|
5105
|
-
undo,
|
|
5106
|
-
redo,
|
|
5107
|
-
canUndo,
|
|
5108
|
-
canRedo,
|
|
5109
|
-
pause: pauseHistory,
|
|
5110
|
-
resume: resumeHistory
|
|
5157
|
+
fetchYDoc,
|
|
5158
|
+
getStorage,
|
|
5159
|
+
getStorageSnapshot,
|
|
5160
|
+
getStorageStatus,
|
|
5161
|
+
events,
|
|
5162
|
+
// Core
|
|
5163
|
+
getStatus: () => managedSocket.getStatus(),
|
|
5164
|
+
getConnectionState: () => managedSocket.getLegacyStatus(),
|
|
5165
|
+
isSelfAware: () => context.sessionInfo.current !== null,
|
|
5166
|
+
getSelf: () => self.current,
|
|
5167
|
+
// Presence
|
|
5168
|
+
getPresence: () => context.me.current,
|
|
5169
|
+
getOthers: () => context.others.current
|
|
5111
5170
|
},
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
// Core
|
|
5118
|
-
getStatus: () => managedSocket.getStatus(),
|
|
5119
|
-
getConnectionState: () => managedSocket.getLegacyStatus(),
|
|
5120
|
-
isSelfAware: () => context.sessionInfo.current !== null,
|
|
5121
|
-
getSelf: () => self.current,
|
|
5122
|
-
// Presence
|
|
5123
|
-
getPresence: () => context.me.current,
|
|
5124
|
-
getOthers: () => context.others.current
|
|
5125
|
-
};
|
|
5171
|
+
// Explictly make the __internal field non-enumerable, to avoid aggressive
|
|
5172
|
+
// freezing when used with Immer
|
|
5173
|
+
"__internal",
|
|
5174
|
+
{ enumerable: false }
|
|
5175
|
+
);
|
|
5126
5176
|
}
|
|
5127
5177
|
function makeClassicSubscribeFn(events) {
|
|
5128
5178
|
function subscribeToLiveStructureDeeply(node, callback) {
|
|
@@ -5220,13 +5270,7 @@ function makeCreateSocketDelegateForRoom(liveblocksServer, WebSocketPolyfill) {
|
|
|
5220
5270
|
}
|
|
5221
5271
|
const token = richToken.raw;
|
|
5222
5272
|
return new ws(
|
|
5223
|
-
`${liveblocksServer}/?token=${token}&version=${
|
|
5224
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
5225
|
-
// @ts-ignore (PKG_VERSION will be injected by the build script)
|
|
5226
|
-
true ? (
|
|
5227
|
-
/* istanbul ignore next */
|
|
5228
|
-
"1.1.5-test2"
|
|
5229
|
-
) : "dev"}`
|
|
5273
|
+
`${liveblocksServer}/?token=${token}&version=${PKG_VERSION || "dev"}`
|
|
5230
5274
|
);
|
|
5231
5275
|
};
|
|
5232
5276
|
}
|
|
@@ -5641,7 +5685,7 @@ function patchLiveObjectKey(liveObject, key, prev, next) {
|
|
|
5641
5685
|
if (process.env.NODE_ENV !== "production") {
|
|
5642
5686
|
const nonSerializableValue = findNonSerializableValue(next);
|
|
5643
5687
|
if (nonSerializableValue) {
|
|
5644
|
-
|
|
5688
|
+
error2(
|
|
5645
5689
|
`New state path: '${nonSerializableValue.path}' value: '${String(
|
|
5646
5690
|
nonSerializableValue.value
|
|
5647
5691
|
)}' is not serializable.
|
|
@@ -5868,45 +5912,8 @@ var WebsocketCloseCodes = /* @__PURE__ */ ((WebsocketCloseCodes2) => {
|
|
|
5868
5912
|
return WebsocketCloseCodes2;
|
|
5869
5913
|
})(WebsocketCloseCodes || {});
|
|
5870
5914
|
|
|
5871
|
-
// src/dupe-detection.ts
|
|
5872
|
-
var g = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {};
|
|
5873
|
-
var crossLinkedDocs = "https://liveblocks.io/errors/cross-linked";
|
|
5874
|
-
var dupesDocs = "https://liveblocks.io/errors/dupes";
|
|
5875
|
-
function error2(msg) {
|
|
5876
|
-
if (process.env.NODE_ENV === "production") {
|
|
5877
|
-
console.error(msg);
|
|
5878
|
-
} else {
|
|
5879
|
-
throw new Error(msg);
|
|
5880
|
-
}
|
|
5881
|
-
}
|
|
5882
|
-
function detectDupes(pkgName, pkgVersion, pkgFormat) {
|
|
5883
|
-
const pkgId = Symbol.for(pkgName);
|
|
5884
|
-
const pkgBuildInfo = `${pkgVersion} (${pkgFormat})`;
|
|
5885
|
-
if (!g[pkgId]) {
|
|
5886
|
-
g[pkgId] = pkgBuildInfo;
|
|
5887
|
-
} else {
|
|
5888
|
-
const msg = `Multiple copies of Liveblocks are being loaded in your project. This will cause issues! See ${dupesDocs}
|
|
5889
|
-
|
|
5890
|
-
Conflicting copies in your bundle:
|
|
5891
|
-
- ${pkgName} ${g[pkgId]} (already loaded)
|
|
5892
|
-
- ${pkgName} ${pkgBuildInfo} (trying to load this now)`;
|
|
5893
|
-
error2(msg);
|
|
5894
|
-
}
|
|
5895
|
-
if (pkgVersion !== "1.1.5-test2") {
|
|
5896
|
-
error2(
|
|
5897
|
-
`Cross-linked versions of Liveblocks found, which will cause issues! See ${crossLinkedDocs}
|
|
5898
|
-
|
|
5899
|
-
Conflicts:
|
|
5900
|
-
- @liveblocks/core is at ${"1.1.5-test2"}
|
|
5901
|
-
- ${pkgName} is at ${pkgVersion}
|
|
5902
|
-
|
|
5903
|
-
Always upgrade all Liveblocks packages to the same version number.`
|
|
5904
|
-
);
|
|
5905
|
-
}
|
|
5906
|
-
}
|
|
5907
|
-
|
|
5908
5915
|
// src/index.ts
|
|
5909
|
-
detectDupes(
|
|
5916
|
+
detectDupes(PKG_NAME, PKG_VERSION, PKG_FORMAT);
|
|
5910
5917
|
|
|
5911
5918
|
|
|
5912
5919
|
|