@liveblocks/core 3.13.2 → 3.13.3-rc1
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.cjs +50 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +50 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -483,7 +483,7 @@ type DeleteCrdtOp = {
|
|
|
483
483
|
readonly id: string;
|
|
484
484
|
readonly type: OpCode.DELETE_CRDT;
|
|
485
485
|
};
|
|
486
|
-
type
|
|
486
|
+
type IgnoredOp = {
|
|
487
487
|
readonly type: OpCode.DELETE_CRDT;
|
|
488
488
|
readonly id: "ACK";
|
|
489
489
|
readonly opId: string;
|
|
@@ -514,7 +514,7 @@ type ClientWireOp = Op & HasOpId;
|
|
|
514
514
|
* 2. AckOp — Our op was seen but intentionally ignored (still counts as ack)
|
|
515
515
|
* 3. Op without opId — Another client's op being forwarded to us
|
|
516
516
|
*/
|
|
517
|
-
type ServerWireOp = ClientWireOp |
|
|
517
|
+
type ServerWireOp = ClientWireOp | IgnoredOp | TheirOp;
|
|
518
518
|
type TheirOp = DistributiveOmit<Op, "opId"> & {
|
|
519
519
|
opId?: undefined;
|
|
520
520
|
};
|
|
@@ -5243,4 +5243,4 @@ type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (EnsureJson
|
|
|
5243
5243
|
[K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
|
|
5244
5244
|
};
|
|
5245
5245
|
|
|
5246
|
-
export { type
|
|
5246
|
+
export { type ActivityData, type AiAssistantContentPart, type AiAssistantMessage, type AiChat, type AiChatMessage, type AiChatsQuery, type AiKnowledgeRetrievalPart, type AiKnowledgeSource, type AiOpaqueToolDefinition, type AiOpaqueToolInvocationProps, type AiReasoningPart, type AiRetrievalPart, type AiSourcesPart, type AiTextPart, type AiToolDefinition, type AiToolExecuteCallback, type AiToolExecuteContext, type AiToolInvocationPart, type AiToolInvocationProps, type AiToolTypePack, type AiUrlSource, type AiUserMessage, type AiWebRetrievalPart, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, type BaseGroupInfo, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type ClientWireOp, type CommentAttachment, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentLocalAttachment, type CommentMixedAttachment, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, type CommentsEventServerMsg, type ContextualPromptContext, type ContextualPromptResponse, type CopilotId, CrdtType, type CreateListOp, type CreateManagedPoolOptions, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type Cursor, type CustomAuthenticationResult, type DAD, type DCM, type DE, type DGI, type DP, type DRI, type DS, type DTM, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, Deque, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type GroupData, type GroupDataPlain, type GroupMemberData, type GroupMentionData, type GroupScopes, type HasOpId, type History, type HistoryVersion, HttpError, type ISODateString, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IdTuple, type IgnoredOp, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InferFromSchema, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LargeMessageStrategy, type LayerKey, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, MENTION_CHARACTER, type ManagedPool, type MentionData, type MessageId, MutableSignal, type NoInfr, type NodeMap, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, type NotificationSettings, type NotificationSettingsPlain, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialNotificationSettings, type PartialUnless, type Patchable, Permission, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type RejectedStorageOpServerMsg, type Relax, type RenderableToolResultResponse, type Resolve, type ResolveGroupsInfoArgs, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomStateServerMsg, type RoomSubscriptionSettings, type SearchCommentsResult, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type ServerWireOp, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageStateServerMsg, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SubscriptionData, type SubscriptionDataPlain, type SubscriptionDeleteInfo, type SubscriptionDeleteInfoPlain, type SubscriptionKey, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type ToolResultResponse, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type UrlMetadata, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserMentionData, type UserRoomSubscriptionSettings, type UserSubscriptionData, type UserSubscriptionDataPlain, WebsocketCloseCodes, type WithNavigation, type WithOptional, type WithRequired, type YDocUpdateServerMsg, type YjsSyncStatus, asPos, assert, assertNever, autoRetry, b64decode, batch, checkBounds, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToGroupData, convertToInboxNotificationData, convertToSubscriptionData, convertToThreadData, convertToUserSubscriptionData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createManagedPool, createNotificationSettings, createThreadId, defineAiTool, deprecate, deprecateIf, detectDupes, entries, errorIf, findLastIndex, freeze, generateUrl, getMentionsFromCommentBody, getSubscriptionKey, html, htmlSafe, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isNotificationChannelEnabled, isNumberOperator, isPlainObject, isStartsWithOperator, isUrl, kInternal, keys, legacy_patchImmutableObject, lsonToJson, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, patchNotificationSettings, raise, resolveMentionsInCommentBody, sanitizeUrl, shallow, shallow2, stableStringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, url, urljoin, wait, warnOnce, warnOnceIf, withTimeout };
|
package/dist/index.d.ts
CHANGED
|
@@ -483,7 +483,7 @@ type DeleteCrdtOp = {
|
|
|
483
483
|
readonly id: string;
|
|
484
484
|
readonly type: OpCode.DELETE_CRDT;
|
|
485
485
|
};
|
|
486
|
-
type
|
|
486
|
+
type IgnoredOp = {
|
|
487
487
|
readonly type: OpCode.DELETE_CRDT;
|
|
488
488
|
readonly id: "ACK";
|
|
489
489
|
readonly opId: string;
|
|
@@ -514,7 +514,7 @@ type ClientWireOp = Op & HasOpId;
|
|
|
514
514
|
* 2. AckOp — Our op was seen but intentionally ignored (still counts as ack)
|
|
515
515
|
* 3. Op without opId — Another client's op being forwarded to us
|
|
516
516
|
*/
|
|
517
|
-
type ServerWireOp = ClientWireOp |
|
|
517
|
+
type ServerWireOp = ClientWireOp | IgnoredOp | TheirOp;
|
|
518
518
|
type TheirOp = DistributiveOmit<Op, "opId"> & {
|
|
519
519
|
opId?: undefined;
|
|
520
520
|
};
|
|
@@ -5243,4 +5243,4 @@ type EnsureJson<T> = T extends Json ? T : T extends Array<infer I> ? (EnsureJson
|
|
|
5243
5243
|
[K in keyof T as EnsureJson<T[K]> extends never ? never : K]: EnsureJson<T[K]>;
|
|
5244
5244
|
};
|
|
5245
5245
|
|
|
5246
|
-
export { type
|
|
5246
|
+
export { type ActivityData, type AiAssistantContentPart, type AiAssistantMessage, type AiChat, type AiChatMessage, type AiChatsQuery, type AiKnowledgeRetrievalPart, type AiKnowledgeSource, type AiOpaqueToolDefinition, type AiOpaqueToolInvocationProps, type AiReasoningPart, type AiRetrievalPart, type AiSourcesPart, type AiTextPart, type AiToolDefinition, type AiToolExecuteCallback, type AiToolExecuteContext, type AiToolInvocationPart, type AiToolInvocationProps, type AiToolTypePack, type AiUrlSource, type AiUserMessage, type AiWebRetrievalPart, type AsyncError, type AsyncLoading, type AsyncResult, type AsyncSuccess, type Awaitable, type BaseActivitiesData, type BaseAuthResult, type BaseGroupInfo, type BaseMetadata, type BaseRoomInfo, type BaseUserMeta, type Brand, type BroadcastEventClientMsg, type BroadcastOptions, type BroadcastedEventServerMsg, type Client, type ClientMsg, ClientMsgCode, type ClientOptions, type ClientWireOp, type CommentAttachment, type CommentBody, type CommentBodyBlockElement, type CommentBodyElement, type CommentBodyInlineElement, type CommentBodyLink, type CommentBodyLinkElementArgs, type CommentBodyMention, type CommentBodyMentionElementArgs, type CommentBodyParagraph, type CommentBodyParagraphElementArgs, type CommentBodyText, type CommentBodyTextElementArgs, type CommentData, type CommentDataPlain, type CommentLocalAttachment, type CommentMixedAttachment, type CommentReaction, type CommentUserReaction, type CommentUserReactionPlain, type CommentsEventServerMsg, type ContextualPromptContext, type ContextualPromptResponse, type CopilotId, CrdtType, type CreateListOp, type CreateManagedPoolOptions, type CreateMapOp, type CreateObjectOp, type CreateOp, type CreateRegisterOp, type Cursor, type CustomAuthenticationResult, type DAD, type DCM, type DE, type DGI, type DP, type DRI, type DS, type DTM, type DU, DefaultMap, type Delegates, type DeleteCrdtOp, type DeleteObjectKeyOp, Deque, DerivedSignal, DevToolsTreeNode as DevTools, protocol as DevToolsMsg, type DistributiveOmit, type EnsureJson, type EnterOptions, type EventSource, type FetchStorageClientMsg, type FetchYDocClientMsg, type GetThreadsOptions, type GroupData, type GroupDataPlain, type GroupMemberData, type GroupMentionData, type GroupScopes, type HasOpId, type History, type HistoryVersion, HttpError, type ISODateString, type ISignal, type IUserInfo, type IWebSocket, type IWebSocketCloseEvent, type IWebSocketEvent, type IWebSocketInstance, type IWebSocketMessageEvent, type IYjsProvider, type IdTuple, type IgnoredOp, type Immutable, type InboxNotificationCustomData, type InboxNotificationCustomDataPlain, type InboxNotificationData, type InboxNotificationDataPlain, type InboxNotificationDeleteInfo, type InboxNotificationTextMentionData, type InboxNotificationTextMentionDataPlain, type InboxNotificationThreadData, type InboxNotificationThreadDataPlain, type InferFromSchema, type Json, type JsonArray, type JsonObject, type JsonScalar, type KDAD, type LargeMessageStrategy, type LayerKey, LiveList, type LiveListUpdate, LiveMap, type LiveMapUpdate, type LiveNode, LiveObject, type LiveObjectUpdate, type LiveStructure, LiveblocksError, type LiveblocksErrorContext, type LostConnectionEvent, type Lson, type LsonObject, MENTION_CHARACTER, type ManagedPool, type MentionData, type MessageId, MutableSignal, type NoInfr, type NodeMap, type NotificationChannel, type NotificationChannelSettings, type NotificationKind, type NotificationSettings, type NotificationSettingsPlain, type Observable, type Op, OpCode, type OpaqueClient, type OpaqueRoom, type OptionalTupleUnless, type OthersEvent, type ParentToChildNodeMap, type PartialNotificationSettings, type PartialUnless, type Patchable, Permission, type PlainLson, type PlainLsonFields, type PlainLsonList, type PlainLsonMap, type PlainLsonObject, type Poller, type PrivateClientApi, type PrivateRoomApi, Promise_withResolvers, type QueryMetadata, type QueryParams, type RejectedStorageOpServerMsg, type Relax, type RenderableToolResultResponse, type Resolve, type ResolveGroupsInfoArgs, type ResolveMentionSuggestionsArgs, type ResolveRoomsInfoArgs, type ResolveUsersArgs, type Room, type RoomEventMessage, type RoomStateServerMsg, type RoomSubscriptionSettings, type SearchCommentsResult, type SerializedChild, type SerializedCrdt, type SerializedList, type SerializedMap, type SerializedObject, type SerializedRegister, type SerializedRootObject, type ServerMsg, ServerMsgCode, type ServerWireOp, type SetParentKeyOp, Signal, type SignalType, SortedList, type Status, type StorageStateServerMsg, type StorageStatus, type StorageUpdate, type StringifyCommentBodyElements, type StringifyCommentBodyOptions, type SubscriptionData, type SubscriptionDataPlain, type SubscriptionDeleteInfo, type SubscriptionDeleteInfoPlain, type SubscriptionKey, type SyncSource, type SyncStatus, TextEditorType, type ThreadData, type ThreadDataPlain, type ThreadDataWithDeleteInfo, type ThreadDeleteInfo, type ToImmutable, type ToJson, type ToolResultResponse, type URLSafeString, type UnsubscribeCallback, type UpdateObjectOp, type UpdatePresenceClientMsg, type UpdatePresenceServerMsg, type UpdateStorageClientMsg, type UpdateStorageServerMsg, type UpdateYDocClientMsg, type UploadAttachmentOptions, type UrlMetadata, type User, type UserJoinServerMsg, type UserLeftServerMsg, type UserMentionData, type UserRoomSubscriptionSettings, type UserSubscriptionData, type UserSubscriptionDataPlain, WebsocketCloseCodes, type WithNavigation, type WithOptional, type WithRequired, type YDocUpdateServerMsg, type YjsSyncStatus, asPos, assert, assertNever, autoRetry, b64decode, batch, checkBounds, chunk, cloneLson, compactObject, fancyConsole as console, convertToCommentData, convertToCommentUserReaction, convertToGroupData, convertToInboxNotificationData, convertToSubscriptionData, convertToThreadData, convertToUserSubscriptionData, createClient, createCommentAttachmentId, createCommentId, createInboxNotificationId, createManagedPool, createNotificationSettings, createThreadId, defineAiTool, deprecate, deprecateIf, detectDupes, entries, errorIf, findLastIndex, freeze, generateUrl, getMentionsFromCommentBody, getSubscriptionKey, html, htmlSafe, isCommentBodyLink, isCommentBodyMention, isCommentBodyText, isJsonArray, isJsonObject, isJsonScalar, isLiveNode, isNotificationChannelEnabled, isNumberOperator, isPlainObject, isStartsWithOperator, isUrl, kInternal, keys, legacy_patchImmutableObject, lsonToJson, makeAbortController, makeEventSource, makePoller, makePosition, mapValues, memoizeOnSuccess, nanoid, nn, objectToQuery, patchLiveObjectKey, patchNotificationSettings, raise, resolveMentionsInCommentBody, sanitizeUrl, shallow, shallow2, stableStringify, stringifyCommentBody, throwUsageError, toPlainLson, tryParseJson, url, urljoin, wait, warnOnce, warnOnceIf, withTimeout };
|
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.13.
|
|
9
|
+
var PKG_VERSION = "3.13.3-rc1";
|
|
10
10
|
var PKG_FORMAT = "esm";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -2760,6 +2760,14 @@ var FSM = class {
|
|
|
2760
2760
|
// `foo.bar.*`, then `foo.*`, and finally, `*`.
|
|
2761
2761
|
//
|
|
2762
2762
|
#cleanupStack;
|
|
2763
|
+
//
|
|
2764
|
+
// The entry times stack tracks when each state level was entered, using
|
|
2765
|
+
// performance.now() timestamps. This parallels the cleanup stack structure.
|
|
2766
|
+
//
|
|
2767
|
+
// For example, if you are in state `foo.bar.qux`, the stack contains:
|
|
2768
|
+
// [timestamp for *, timestamp for foo.*, timestamp for foo.bar.*, timestamp for foo.bar.qux]
|
|
2769
|
+
//
|
|
2770
|
+
#entryTimesStack;
|
|
2763
2771
|
#enterFns;
|
|
2764
2772
|
// Used to provide better error messages
|
|
2765
2773
|
#knownEventTypes;
|
|
@@ -2816,6 +2824,7 @@ var FSM = class {
|
|
|
2816
2824
|
this.#states = /* @__PURE__ */ new Set();
|
|
2817
2825
|
this.#enterFns = /* @__PURE__ */ new Map();
|
|
2818
2826
|
this.#cleanupStack = [];
|
|
2827
|
+
this.#entryTimesStack = [];
|
|
2819
2828
|
this.#knownEventTypes = /* @__PURE__ */ new Set();
|
|
2820
2829
|
this.#allowedTransitions = /* @__PURE__ */ new Map();
|
|
2821
2830
|
this.#currentContext = new SafeContext(initialContext);
|
|
@@ -2824,14 +2833,16 @@ var FSM = class {
|
|
|
2824
2833
|
willTransition: makeEventSource(),
|
|
2825
2834
|
didIgnoreEvent: makeEventSource(),
|
|
2826
2835
|
willExitState: makeEventSource(),
|
|
2827
|
-
didEnterState: makeEventSource()
|
|
2836
|
+
didEnterState: makeEventSource(),
|
|
2837
|
+
didExitState: makeEventSource()
|
|
2828
2838
|
};
|
|
2829
2839
|
this.events = {
|
|
2830
2840
|
didReceiveEvent: this.#eventHub.didReceiveEvent.observable,
|
|
2831
2841
|
willTransition: this.#eventHub.willTransition.observable,
|
|
2832
2842
|
didIgnoreEvent: this.#eventHub.didIgnoreEvent.observable,
|
|
2833
2843
|
willExitState: this.#eventHub.willExitState.observable,
|
|
2834
|
-
didEnterState: this.#eventHub.didEnterState.observable
|
|
2844
|
+
didEnterState: this.#eventHub.didEnterState.observable,
|
|
2845
|
+
didExitState: this.#eventHub.didExitState.observable
|
|
2835
2846
|
};
|
|
2836
2847
|
}
|
|
2837
2848
|
get context() {
|
|
@@ -3017,10 +3028,23 @@ var FSM = class {
|
|
|
3017
3028
|
*/
|
|
3018
3029
|
#exit(levels) {
|
|
3019
3030
|
this.#eventHub.willExitState.notify(this.currentState);
|
|
3031
|
+
const now2 = performance.now();
|
|
3032
|
+
const parts = this.currentState.split(".");
|
|
3020
3033
|
this.#currentContext.allowPatching((patchableContext) => {
|
|
3021
3034
|
levels = levels ?? this.#cleanupStack.length;
|
|
3022
3035
|
for (let i = 0; i < levels; i++) {
|
|
3023
3036
|
this.#cleanupStack.pop()?.(patchableContext);
|
|
3037
|
+
const entryTime = this.#entryTimesStack.pop();
|
|
3038
|
+
if (entryTime !== void 0 && // ...but avoid computing state names if nobody is listening
|
|
3039
|
+
this.#eventHub.didExitState.count() > 0) {
|
|
3040
|
+
const depth = this.#entryTimesStack.length;
|
|
3041
|
+
if (depth === 0) continue;
|
|
3042
|
+
const state = depth === parts.length ? this.currentState : `${parts.slice(0, depth).join(".")}.*`;
|
|
3043
|
+
this.#eventHub.didExitState.notify({
|
|
3044
|
+
state,
|
|
3045
|
+
durationMs: now2 - entryTime
|
|
3046
|
+
});
|
|
3047
|
+
}
|
|
3024
3048
|
}
|
|
3025
3049
|
});
|
|
3026
3050
|
}
|
|
@@ -3033,6 +3057,7 @@ var FSM = class {
|
|
|
3033
3057
|
this.currentState,
|
|
3034
3058
|
levels ?? this.currentState.split(".").length + 1
|
|
3035
3059
|
);
|
|
3060
|
+
const now2 = performance.now();
|
|
3036
3061
|
this.#currentContext.allowPatching((patchableContext) => {
|
|
3037
3062
|
for (const pattern of enterPatterns) {
|
|
3038
3063
|
const enterFn = this.#enterFns.get(pattern);
|
|
@@ -3042,6 +3067,7 @@ var FSM = class {
|
|
|
3042
3067
|
} else {
|
|
3043
3068
|
this.#cleanupStack.push(null);
|
|
3044
3069
|
}
|
|
3070
|
+
this.#entryTimesStack.push(now2);
|
|
3045
3071
|
}
|
|
3046
3072
|
});
|
|
3047
3073
|
this.#eventHub.didEnterState.notify(this.currentState);
|
|
@@ -3259,23 +3285,20 @@ function isCloseEvent(error3) {
|
|
|
3259
3285
|
return !(error3 instanceof Error) && error3.type === "close";
|
|
3260
3286
|
}
|
|
3261
3287
|
function enableTracing(machine) {
|
|
3262
|
-
const start = (/* @__PURE__ */ new Date()).getTime();
|
|
3263
3288
|
function log2(...args) {
|
|
3264
|
-
warn(
|
|
3265
|
-
`${(((/* @__PURE__ */ new Date()).getTime() - start) / 1e3).toFixed(2)} [FSM #${machine.id}]`,
|
|
3266
|
-
...args
|
|
3267
|
-
);
|
|
3289
|
+
warn(`[FSM #${machine.id}]`, ...args);
|
|
3268
3290
|
}
|
|
3269
3291
|
const unsubs = [
|
|
3270
3292
|
machine.events.didReceiveEvent.subscribe((e) => log2(`Event ${e.type}`)),
|
|
3271
3293
|
machine.events.willTransition.subscribe(
|
|
3272
3294
|
({ from, to }) => log2("Transitioning", from, "\u2192", to)
|
|
3273
3295
|
),
|
|
3296
|
+
machine.events.didExitState.subscribe(
|
|
3297
|
+
({ state, durationMs }) => log2(`Exited ${state} after ${durationMs.toFixed(0)}ms`)
|
|
3298
|
+
),
|
|
3274
3299
|
machine.events.didIgnoreEvent.subscribe(
|
|
3275
3300
|
(e) => log2("Ignored event", e.type, e, "(current state won't handle it)")
|
|
3276
3301
|
)
|
|
3277
|
-
// machine.events.willExitState.subscribe((s) => log("Exiting state", s)),
|
|
3278
|
-
// machine.events.didEnterState.subscribe((s) => log("Entering state", s)),
|
|
3279
3302
|
];
|
|
3280
3303
|
return () => {
|
|
3281
3304
|
for (const unsub of unsubs) {
|
|
@@ -3416,6 +3439,8 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
3416
3439
|
// OK state. This is done by resolving the Promise.
|
|
3417
3440
|
//
|
|
3418
3441
|
async (ctx, signal) => {
|
|
3442
|
+
const socketEpoch = performance.now();
|
|
3443
|
+
let socketOpenAt = null;
|
|
3419
3444
|
let capturedPrematureEvent = null;
|
|
3420
3445
|
let unconfirmedSocket = null;
|
|
3421
3446
|
const connect$ = new Promise(
|
|
@@ -3437,6 +3462,12 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
3437
3462
|
function waitForActorId(event) {
|
|
3438
3463
|
const serverMsg = tryParseJson(event.data);
|
|
3439
3464
|
if (serverMsg?.type === ServerMsgCode.ROOM_STATE) {
|
|
3465
|
+
if (options.enableDebugLogging && socketOpenAt !== null) {
|
|
3466
|
+
const elapsed = performance.now() - socketOpenAt;
|
|
3467
|
+
warn(
|
|
3468
|
+
`[FSM #${machine.id}] Socket open \u2192 ROOM_STATE: ${elapsed.toFixed(0)}ms`
|
|
3469
|
+
);
|
|
3470
|
+
}
|
|
3440
3471
|
didReceiveActor();
|
|
3441
3472
|
}
|
|
3442
3473
|
}
|
|
@@ -3447,6 +3478,13 @@ function createConnectionStateMachine(delegates, options) {
|
|
|
3447
3478
|
socket.addEventListener("error", reject);
|
|
3448
3479
|
socket.addEventListener("close", reject);
|
|
3449
3480
|
socket.addEventListener("open", () => {
|
|
3481
|
+
socketOpenAt = performance.now();
|
|
3482
|
+
if (options.enableDebugLogging) {
|
|
3483
|
+
const elapsed = socketOpenAt - socketEpoch;
|
|
3484
|
+
warn(
|
|
3485
|
+
`[FSM #${machine.id}] Socket epoch \u2192 open: ${elapsed.toFixed(0)}ms`
|
|
3486
|
+
);
|
|
3487
|
+
}
|
|
3450
3488
|
socket.addEventListener("error", onSocketError);
|
|
3451
3489
|
socket.addEventListener("close", onSocketClose);
|
|
3452
3490
|
const unsub = () => {
|
|
@@ -5952,7 +5990,7 @@ var OpCode = Object.freeze({
|
|
|
5952
5990
|
CREATE_MAP: 7,
|
|
5953
5991
|
CREATE_REGISTER: 8
|
|
5954
5992
|
});
|
|
5955
|
-
function
|
|
5993
|
+
function isIgnoredOp(op) {
|
|
5956
5994
|
return op.type === OpCode.DELETE_CRDT && op.id === "ACK";
|
|
5957
5995
|
}
|
|
5958
5996
|
|
|
@@ -9292,7 +9330,7 @@ function createRoom(options, config) {
|
|
|
9292
9330
|
};
|
|
9293
9331
|
}
|
|
9294
9332
|
function applyOp(op, source) {
|
|
9295
|
-
if (
|
|
9333
|
+
if (isIgnoredOp(op)) {
|
|
9296
9334
|
return { modified: false };
|
|
9297
9335
|
}
|
|
9298
9336
|
switch (op.type) {
|