@rocicorp/zero 0.19.2025041601 → 0.19.2025042200
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/out/analyze-query/src/bin-analyze.js +2 -4
- package/out/analyze-query/src/bin-analyze.js.map +1 -1
- package/out/analyze-query/src/bin-cache-stats.js +75 -5
- package/out/analyze-query/src/bin-cache-stats.js.map +1 -1
- package/out/{chunk-TOXB4NRA.js → chunk-2QVFOPGX.js} +15 -21
- package/out/chunk-2QVFOPGX.js.map +7 -0
- package/out/{chunk-PFL3ILT2.js → chunk-I5KZ62HL.js} +2 -2
- package/out/{chunk-NIDZOMES.js → chunk-ZEL4YSUP.js} +271 -122
- package/out/{chunk-NIDZOMES.js.map → chunk-ZEL4YSUP.js.map} +4 -4
- package/out/{inspector-3FBM22O3.js → inspector-T4TQPT2K.js} +5 -6
- package/out/{inspector-3FBM22O3.js.map → inspector-T4TQPT2K.js.map} +2 -2
- package/out/react.js +1 -1
- package/out/react.js.map +1 -1
- package/out/shared/src/logging-test-utils.d.ts +1 -1
- package/out/shared/src/logging-test-utils.d.ts.map +1 -1
- package/out/solid.js +3 -3
- package/out/zero-cache/src/server/syncer.d.ts.map +1 -1
- package/out/zero-cache/src/server/syncer.js +1 -0
- package/out/zero-cache/src/server/syncer.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/initial-sync.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/initial-sync.js +2 -2
- package/out/zero-cache/src/services/change-source/pg/initial-sync.js.map +1 -1
- package/out/zero-cache/src/services/mutagen/mutagen.d.ts +1 -1
- package/out/zero-cache/src/services/mutagen/mutagen.d.ts.map +1 -1
- package/out/zero-cache/src/services/mutagen/mutagen.js +1 -1
- package/out/zero-cache/src/services/mutagen/mutagen.js.map +1 -1
- package/out/zero-cache/src/services/mutagen/pusher.d.ts +2 -2
- package/out/zero-cache/src/services/mutagen/pusher.d.ts.map +1 -1
- package/out/zero-cache/src/services/mutagen/pusher.js +2 -2
- package/out/zero-cache/src/services/mutagen/pusher.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/client-handler.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/client-handler.js +1 -0
- package/out/zero-cache/src/services/view-syncer/client-handler.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr-store.js +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr-store.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/key-columns.js +1 -1
- package/out/zero-cache/src/services/view-syncer/key-columns.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/view-syncer.js +5 -2
- package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
- package/out/zero-cache/src/types/schema-versions.js +1 -1
- package/out/zero-cache/src/types/schema-versions.js.map +1 -1
- package/out/zero-cache/src/workers/connection.d.ts +1 -1
- package/out/zero-cache/src/workers/connection.d.ts.map +1 -1
- package/out/zero-cache/src/workers/connection.js +2 -2
- package/out/zero-cache/src/workers/connection.js.map +1 -1
- package/out/zero-cache/src/workers/syncer-ws-message-handler.js +1 -1
- package/out/zero-cache/src/workers/syncer-ws-message-handler.js.map +1 -1
- package/out/zero-cache/src/workers/syncer.d.ts.map +1 -1
- package/out/zero-cache/src/workers/syncer.js +4 -1
- package/out/zero-cache/src/workers/syncer.js.map +1 -1
- package/out/zero-client/src/client/context.d.ts +3 -3
- package/out/zero-client/src/client/context.d.ts.map +1 -1
- package/out/zero-client/src/client/custom.d.ts +3 -3
- package/out/zero-client/src/client/custom.d.ts.map +1 -1
- package/out/zero-client/src/client/delete-clients-manager.d.ts +2 -2
- package/out/zero-client/src/client/delete-clients-manager.d.ts.map +1 -1
- package/out/zero-client/src/client/inspector/inspector.d.ts +1 -1
- package/out/zero-client/src/client/inspector/inspector.d.ts.map +1 -1
- package/out/zero-client/src/client/metrics.d.ts +4 -5
- package/out/zero-client/src/client/metrics.d.ts.map +1 -1
- package/out/zero-client/src/client/mutation-tracker.d.ts +3 -3
- package/out/zero-client/src/client/mutation-tracker.d.ts.map +1 -1
- package/out/zero-client/src/client/on-error-kind-enum.d.ts +17 -0
- package/out/zero-client/src/client/on-error-kind-enum.d.ts.map +1 -0
- package/out/zero-client/src/client/on-error-kind.d.ts +5 -0
- package/out/zero-client/src/client/on-error-kind.d.ts.map +1 -0
- package/out/zero-client/src/client/on-error.d.ts +9 -0
- package/out/zero-client/src/client/on-error.d.ts.map +1 -0
- package/out/zero-client/src/client/options.d.ts +18 -4
- package/out/zero-client/src/client/options.d.ts.map +1 -1
- package/out/zero-client/src/client/reload-error-handler.d.ts +5 -3
- package/out/zero-client/src/client/reload-error-handler.d.ts.map +1 -1
- package/out/zero-client/src/client/server-error.d.ts +1 -3
- package/out/zero-client/src/client/server-error.d.ts.map +1 -1
- package/out/zero-client/src/client/update-needed-reason-type-enum.d.ts +20 -0
- package/out/zero-client/src/client/update-needed-reason-type-enum.d.ts.map +1 -0
- package/out/zero-client/src/client/update-needed-reason-type.d.ts +5 -0
- package/out/zero-client/src/client/update-needed-reason-type.d.ts.map +1 -0
- package/out/zero-client/src/client/zero-log-context.d.ts +7 -0
- package/out/zero-client/src/client/zero-log-context.d.ts.map +1 -0
- package/out/zero-client/src/client/zero-poke-handler.d.ts +2 -2
- package/out/zero-client/src/client/zero-poke-handler.d.ts.map +1 -1
- package/out/zero-client/src/client/zero.d.ts +2 -2
- package/out/zero-client/src/client/zero.d.ts.map +1 -1
- package/out/zero-client/src/mod.d.ts +4 -0
- package/out/zero-client/src/mod.d.ts.map +1 -1
- package/out/zero-protocol/src/error-kind.d.ts +5 -0
- package/out/zero-protocol/src/error-kind.d.ts.map +1 -0
- package/out/zero-protocol/src/error-kind.js +3 -0
- package/out/zero-protocol/src/error-kind.js.map +1 -0
- package/out/zero-protocol/src/error.d.ts +2 -0
- package/out/zero-protocol/src/error.d.ts.map +1 -1
- package/out/zero-protocol/src/error.js +2 -1
- package/out/zero-protocol/src/error.js.map +1 -1
- package/out/zero-react/src/use-query.d.ts +1 -1
- package/out/zero.js +10 -4
- package/out/zql/src/query/query-impl.d.ts +4 -5
- package/out/zql/src/query/query-impl.d.ts.map +1 -1
- package/out/zql/src/query/query-impl.js +14 -14
- package/out/zql/src/query/query-impl.js.map +1 -1
- package/out/zql/src/query/query.d.ts +6 -7
- package/out/zql/src/query/query.d.ts.map +1 -1
- package/out/zql/src/query/query.js.map +1 -1
- package/package.json +2 -2
- package/out/chunk-TOXB4NRA.js.map +0 -7
- /package/out/{chunk-PFL3ILT2.js.map → chunk-I5KZ62HL.js.map} +0 -0
|
@@ -84,10 +84,9 @@ import {
|
|
|
84
84
|
withRead,
|
|
85
85
|
withWrite,
|
|
86
86
|
withWriteNoImplicitCommit
|
|
87
|
-
} from "./chunk-
|
|
87
|
+
} from "./chunk-I5KZ62HL.js";
|
|
88
88
|
import {
|
|
89
89
|
AbstractQuery,
|
|
90
|
-
DEFAULT_RUN_OPTIONS_UNKNOWN,
|
|
91
90
|
ExpressionBuilder,
|
|
92
91
|
assertJSONObject,
|
|
93
92
|
assertJSONValue,
|
|
@@ -120,8 +119,9 @@ import {
|
|
|
120
119
|
transformFilters,
|
|
121
120
|
valita_exports,
|
|
122
121
|
wrapIterable
|
|
123
|
-
} from "./chunk-
|
|
122
|
+
} from "./chunk-2QVFOPGX.js";
|
|
124
123
|
import {
|
|
124
|
+
__export,
|
|
125
125
|
assert,
|
|
126
126
|
assertArray,
|
|
127
127
|
assertNotNull,
|
|
@@ -5537,6 +5537,45 @@ function canDatabaseBeCollectedAndGetDeletedClientIDs(enableMutationRecovery, pe
|
|
|
5537
5537
|
});
|
|
5538
5538
|
}
|
|
5539
5539
|
|
|
5540
|
+
// ../zero-protocol/src/error-kind-enum.ts
|
|
5541
|
+
var error_kind_enum_exports = {};
|
|
5542
|
+
__export(error_kind_enum_exports, {
|
|
5543
|
+
AuthInvalidated: () => AuthInvalidated,
|
|
5544
|
+
ClientNotFound: () => ClientNotFound,
|
|
5545
|
+
Internal: () => Internal,
|
|
5546
|
+
InvalidConnectionRequest: () => InvalidConnectionRequest,
|
|
5547
|
+
InvalidConnectionRequestBaseCookie: () => InvalidConnectionRequestBaseCookie,
|
|
5548
|
+
InvalidConnectionRequestClientDeleted: () => InvalidConnectionRequestClientDeleted,
|
|
5549
|
+
InvalidConnectionRequestLastMutationID: () => InvalidConnectionRequestLastMutationID,
|
|
5550
|
+
InvalidMessage: () => InvalidMessage,
|
|
5551
|
+
InvalidPush: () => InvalidPush,
|
|
5552
|
+
MutationFailed: () => MutationFailed,
|
|
5553
|
+
MutationRateLimited: () => MutationRateLimited,
|
|
5554
|
+
Rebalance: () => Rebalance,
|
|
5555
|
+
Rehome: () => Rehome,
|
|
5556
|
+
SchemaVersionNotSupported: () => SchemaVersionNotSupported,
|
|
5557
|
+
ServerOverloaded: () => ServerOverloaded,
|
|
5558
|
+
Unauthorized: () => Unauthorized,
|
|
5559
|
+
VersionNotSupported: () => VersionNotSupported
|
|
5560
|
+
});
|
|
5561
|
+
var AuthInvalidated = "AuthInvalidated";
|
|
5562
|
+
var ClientNotFound = "ClientNotFound";
|
|
5563
|
+
var InvalidConnectionRequest = "InvalidConnectionRequest";
|
|
5564
|
+
var InvalidConnectionRequestBaseCookie = "InvalidConnectionRequestBaseCookie";
|
|
5565
|
+
var InvalidConnectionRequestLastMutationID = "InvalidConnectionRequestLastMutationID";
|
|
5566
|
+
var InvalidConnectionRequestClientDeleted = "InvalidConnectionRequestClientDeleted";
|
|
5567
|
+
var InvalidMessage = "InvalidMessage";
|
|
5568
|
+
var InvalidPush = "InvalidPush";
|
|
5569
|
+
var MutationFailed = "MutationFailed";
|
|
5570
|
+
var MutationRateLimited = "MutationRateLimited";
|
|
5571
|
+
var Rebalance = "Rebalance";
|
|
5572
|
+
var Rehome = "Rehome";
|
|
5573
|
+
var Unauthorized = "Unauthorized";
|
|
5574
|
+
var VersionNotSupported = "VersionNotSupported";
|
|
5575
|
+
var SchemaVersionNotSupported = "SchemaVersionNotSupported";
|
|
5576
|
+
var ServerOverloaded = "ServerOverloaded";
|
|
5577
|
+
var Internal = "Internal";
|
|
5578
|
+
|
|
5540
5579
|
// ../zero-schema/src/builder/relationship-builder.ts
|
|
5541
5580
|
function relationships(table2, cb) {
|
|
5542
5581
|
const relationships2 = cb({ many, one });
|
|
@@ -6085,8 +6124,58 @@ function escapeLike(val) {
|
|
|
6085
6124
|
return val.replace(/[%_]/g, "\\$&");
|
|
6086
6125
|
}
|
|
6087
6126
|
|
|
6127
|
+
// ../zero-client/src/client/on-error-kind-enum.ts
|
|
6128
|
+
var on_error_kind_enum_exports = {};
|
|
6129
|
+
__export(on_error_kind_enum_exports, {
|
|
6130
|
+
AuthInvalidated: () => AuthInvalidated,
|
|
6131
|
+
ClientNotFound: () => ClientNotFound,
|
|
6132
|
+
Internal: () => Internal,
|
|
6133
|
+
InvalidConnectionRequest: () => InvalidConnectionRequest,
|
|
6134
|
+
InvalidConnectionRequestBaseCookie: () => InvalidConnectionRequestBaseCookie,
|
|
6135
|
+
InvalidConnectionRequestClientDeleted: () => InvalidConnectionRequestClientDeleted,
|
|
6136
|
+
InvalidConnectionRequestLastMutationID: () => InvalidConnectionRequestLastMutationID,
|
|
6137
|
+
InvalidMessage: () => InvalidMessage,
|
|
6138
|
+
InvalidPush: () => InvalidPush,
|
|
6139
|
+
InvalidState: () => InvalidState,
|
|
6140
|
+
Metrics: () => Metrics,
|
|
6141
|
+
Mutation: () => Mutation,
|
|
6142
|
+
MutationFailed: () => MutationFailed,
|
|
6143
|
+
MutationRateLimited: () => MutationRateLimited,
|
|
6144
|
+
Network: () => Network,
|
|
6145
|
+
NewClientGroup: () => NewClientGroup,
|
|
6146
|
+
Poke: () => Poke,
|
|
6147
|
+
Push: () => Push,
|
|
6148
|
+
Rebalance: () => Rebalance,
|
|
6149
|
+
Rehome: () => Rehome,
|
|
6150
|
+
SchemaVersionNotSupported: () => SchemaVersionNotSupported2,
|
|
6151
|
+
ServerOverloaded: () => ServerOverloaded,
|
|
6152
|
+
Unauthorized: () => Unauthorized,
|
|
6153
|
+
Unknown: () => Unknown,
|
|
6154
|
+
VersionNotSupported: () => VersionNotSupported2
|
|
6155
|
+
});
|
|
6156
|
+
|
|
6157
|
+
// ../zero-client/src/client/update-needed-reason-type-enum.ts
|
|
6158
|
+
var update_needed_reason_type_enum_exports = {};
|
|
6159
|
+
__export(update_needed_reason_type_enum_exports, {
|
|
6160
|
+
NewClientGroup: () => NewClientGroup,
|
|
6161
|
+
SchemaVersionNotSupported: () => SchemaVersionNotSupported2,
|
|
6162
|
+
VersionNotSupported: () => VersionNotSupported2
|
|
6163
|
+
});
|
|
6164
|
+
var NewClientGroup = "NewClientGroup";
|
|
6165
|
+
var VersionNotSupported2 = "VersionNotSupported";
|
|
6166
|
+
var SchemaVersionNotSupported2 = "SchemaVersionNotSupported";
|
|
6167
|
+
|
|
6168
|
+
// ../zero-client/src/client/on-error-kind-enum.ts
|
|
6169
|
+
var Poke = "Poke";
|
|
6170
|
+
var Mutation = "Mutation";
|
|
6171
|
+
var Push = "Push";
|
|
6172
|
+
var Metrics = "Metrics";
|
|
6173
|
+
var Unknown = "Unknown";
|
|
6174
|
+
var InvalidState = "InvalidState";
|
|
6175
|
+
var Network = "Network";
|
|
6176
|
+
|
|
6088
6177
|
// ../zero-client/src/client/zero.ts
|
|
6089
|
-
import
|
|
6178
|
+
import "@rocicorp/logger";
|
|
6090
6179
|
import { resolver as resolver8 } from "@rocicorp/resolver";
|
|
6091
6180
|
|
|
6092
6181
|
// ../zero-protocol/src/delete-clients.ts
|
|
@@ -6148,50 +6237,31 @@ function encodeSecProtocols(initConnectionMessage, authToken) {
|
|
|
6148
6237
|
return encodeURIComponent(btoa(JSON.stringify(protocols)));
|
|
6149
6238
|
}
|
|
6150
6239
|
|
|
6151
|
-
// ../zero-protocol/src/error-kind-enum.ts
|
|
6152
|
-
var AuthInvalidated = "AuthInvalidated";
|
|
6153
|
-
var ClientNotFound = "ClientNotFound";
|
|
6154
|
-
var InvalidConnectionRequest = "InvalidConnectionRequest";
|
|
6155
|
-
var InvalidConnectionRequestBaseCookie = "InvalidConnectionRequestBaseCookie";
|
|
6156
|
-
var InvalidConnectionRequestLastMutationID = "InvalidConnectionRequestLastMutationID";
|
|
6157
|
-
var InvalidConnectionRequestClientDeleted = "InvalidConnectionRequestClientDeleted";
|
|
6158
|
-
var InvalidMessage = "InvalidMessage";
|
|
6159
|
-
var InvalidPush = "InvalidPush";
|
|
6160
|
-
var MutationFailed = "MutationFailed";
|
|
6161
|
-
var MutationRateLimited = "MutationRateLimited";
|
|
6162
|
-
var Rebalance = "Rebalance";
|
|
6163
|
-
var Rehome = "Rehome";
|
|
6164
|
-
var Unauthorized = "Unauthorized";
|
|
6165
|
-
var VersionNotSupported = "VersionNotSupported";
|
|
6166
|
-
var SchemaVersionNotSupported = "SchemaVersionNotSupported";
|
|
6167
|
-
var ServerOverloaded = "ServerOverloaded";
|
|
6168
|
-
var Internal = "Internal";
|
|
6169
|
-
|
|
6170
6240
|
// ../zero-protocol/src/error.ts
|
|
6171
6241
|
var basicErrorKindSchema = valita_exports.union(
|
|
6172
|
-
valita_exports.literal(AuthInvalidated),
|
|
6173
|
-
valita_exports.literal(ClientNotFound),
|
|
6174
|
-
valita_exports.literal(InvalidConnectionRequest),
|
|
6175
|
-
valita_exports.literal(InvalidConnectionRequestBaseCookie),
|
|
6176
|
-
valita_exports.literal(InvalidConnectionRequestLastMutationID),
|
|
6177
|
-
valita_exports.literal(InvalidConnectionRequestClientDeleted),
|
|
6178
|
-
valita_exports.literal(InvalidMessage),
|
|
6179
|
-
valita_exports.literal(InvalidPush),
|
|
6180
|
-
valita_exports.literal(MutationRateLimited),
|
|
6181
|
-
valita_exports.literal(MutationFailed),
|
|
6182
|
-
valita_exports.literal(Unauthorized),
|
|
6183
|
-
valita_exports.literal(VersionNotSupported),
|
|
6184
|
-
valita_exports.literal(SchemaVersionNotSupported),
|
|
6185
|
-
valita_exports.literal(Internal)
|
|
6242
|
+
valita_exports.literal(error_kind_enum_exports.AuthInvalidated),
|
|
6243
|
+
valita_exports.literal(error_kind_enum_exports.ClientNotFound),
|
|
6244
|
+
valita_exports.literal(error_kind_enum_exports.InvalidConnectionRequest),
|
|
6245
|
+
valita_exports.literal(error_kind_enum_exports.InvalidConnectionRequestBaseCookie),
|
|
6246
|
+
valita_exports.literal(error_kind_enum_exports.InvalidConnectionRequestLastMutationID),
|
|
6247
|
+
valita_exports.literal(error_kind_enum_exports.InvalidConnectionRequestClientDeleted),
|
|
6248
|
+
valita_exports.literal(error_kind_enum_exports.InvalidMessage),
|
|
6249
|
+
valita_exports.literal(error_kind_enum_exports.InvalidPush),
|
|
6250
|
+
valita_exports.literal(error_kind_enum_exports.MutationRateLimited),
|
|
6251
|
+
valita_exports.literal(error_kind_enum_exports.MutationFailed),
|
|
6252
|
+
valita_exports.literal(error_kind_enum_exports.Unauthorized),
|
|
6253
|
+
valita_exports.literal(error_kind_enum_exports.VersionNotSupported),
|
|
6254
|
+
valita_exports.literal(error_kind_enum_exports.SchemaVersionNotSupported),
|
|
6255
|
+
valita_exports.literal(error_kind_enum_exports.Internal)
|
|
6186
6256
|
);
|
|
6187
6257
|
var basicErrorBodySchema = valita_exports.object({
|
|
6188
6258
|
kind: basicErrorKindSchema,
|
|
6189
6259
|
message: valita_exports.string()
|
|
6190
6260
|
});
|
|
6191
6261
|
var backoffErrorKindSchema = valita_exports.union(
|
|
6192
|
-
valita_exports.literal(Rebalance),
|
|
6193
|
-
valita_exports.literal(Rehome),
|
|
6194
|
-
valita_exports.literal(ServerOverloaded)
|
|
6262
|
+
valita_exports.literal(error_kind_enum_exports.Rebalance),
|
|
6263
|
+
valita_exports.literal(error_kind_enum_exports.Rehome),
|
|
6264
|
+
valita_exports.literal(error_kind_enum_exports.ServerOverloaded)
|
|
6195
6265
|
);
|
|
6196
6266
|
var backoffBodySchema = valita_exports.object({
|
|
6197
6267
|
kind: backoffErrorKindSchema,
|
|
@@ -6207,6 +6277,10 @@ var backoffBodySchema = valita_exports.object({
|
|
|
6207
6277
|
// reconnect, and not after that.
|
|
6208
6278
|
reconnectParams: valita_exports.record(valita_exports.string()).optional()
|
|
6209
6279
|
});
|
|
6280
|
+
var errorKindSchema = valita_exports.union(
|
|
6281
|
+
basicErrorKindSchema,
|
|
6282
|
+
backoffErrorKindSchema
|
|
6283
|
+
);
|
|
6210
6284
|
var errorBodySchema = valita_exports.union(basicErrorBodySchema, backoffBodySchema);
|
|
6211
6285
|
var errorMessageSchema = valita_exports.tuple([
|
|
6212
6286
|
valita_exports.literal("error"),
|
|
@@ -7703,20 +7777,20 @@ var ZeroContext = class {
|
|
|
7703
7777
|
#commitListeners = /* @__PURE__ */ new Set();
|
|
7704
7778
|
#slowMaterializeThreshold;
|
|
7705
7779
|
#lc;
|
|
7706
|
-
|
|
7780
|
+
assertValidRunOptions;
|
|
7707
7781
|
/**
|
|
7708
7782
|
* Client-side queries start out as "unknown" and are then updated to
|
|
7709
7783
|
* "complete" once the server has sent back the query result.
|
|
7710
7784
|
*/
|
|
7711
7785
|
defaultQueryComplete = false;
|
|
7712
|
-
constructor(lc, mainSources, addQuery, updateQuery, batchViewUpdates, slowMaterializeThreshold,
|
|
7786
|
+
constructor(lc, mainSources, addQuery, updateQuery, batchViewUpdates, slowMaterializeThreshold, assertValidRunOptions3) {
|
|
7713
7787
|
this.#mainSources = mainSources;
|
|
7714
7788
|
this.#addQuery = addQuery;
|
|
7715
7789
|
this.#updateQuery = updateQuery;
|
|
7716
7790
|
this.#batchViewUpdates = batchViewUpdates;
|
|
7717
7791
|
this.#lc = lc;
|
|
7718
7792
|
this.#slowMaterializeThreshold = slowMaterializeThreshold;
|
|
7719
|
-
this.
|
|
7793
|
+
this.assertValidRunOptions = assertValidRunOptions3;
|
|
7720
7794
|
}
|
|
7721
7795
|
getSource(name) {
|
|
7722
7796
|
return this.#mainSources.getSource(name);
|
|
@@ -7787,6 +7861,7 @@ var ZeroContext = class {
|
|
|
7787
7861
|
listener();
|
|
7788
7862
|
} catch (e) {
|
|
7789
7863
|
this.#lc.error?.(
|
|
7864
|
+
error_kind_enum_exports.Internal,
|
|
7790
7865
|
"Failed notifying a commit listener of IVM updates",
|
|
7791
7866
|
e
|
|
7792
7867
|
);
|
|
@@ -8072,15 +8147,11 @@ function makeSchemaCRUD(schema, tx, ivmBranch) {
|
|
|
8072
8147
|
}
|
|
8073
8148
|
);
|
|
8074
8149
|
}
|
|
8075
|
-
function
|
|
8076
|
-
if (options === void 0) {
|
|
8077
|
-
return DEFAULT_RUN_OPTIONS_UNKNOWN;
|
|
8078
|
-
}
|
|
8150
|
+
function assertValidRunOptions(options) {
|
|
8079
8151
|
assert(
|
|
8080
|
-
options
|
|
8152
|
+
options?.type !== "complete",
|
|
8081
8153
|
"Cannot wait for complete results in custom mutations"
|
|
8082
8154
|
);
|
|
8083
|
-
return options;
|
|
8084
8155
|
}
|
|
8085
8156
|
function makeSchemaQuery(lc, schema, ivmBranch, slowMaterializeThreshold) {
|
|
8086
8157
|
const context = new ZeroContext(
|
|
@@ -8091,7 +8162,7 @@ function makeSchemaQuery(lc, schema, ivmBranch, slowMaterializeThreshold) {
|
|
|
8091
8162
|
},
|
|
8092
8163
|
(applyViewUpdates) => applyViewUpdates(),
|
|
8093
8164
|
slowMaterializeThreshold,
|
|
8094
|
-
|
|
8165
|
+
assertValidRunOptions
|
|
8095
8166
|
);
|
|
8096
8167
|
return new Proxy(
|
|
8097
8168
|
{},
|
|
@@ -8436,7 +8507,7 @@ function makeMessage(message, context, logLevel) {
|
|
|
8436
8507
|
}
|
|
8437
8508
|
|
|
8438
8509
|
// ../zero-client/src/client/version.ts
|
|
8439
|
-
var version2 = "0.19.
|
|
8510
|
+
var version2 = "0.19.2025042200";
|
|
8440
8511
|
|
|
8441
8512
|
// ../zero-client/src/client/log-options.ts
|
|
8442
8513
|
var LevelFilterLogSink = class {
|
|
@@ -8633,7 +8704,10 @@ var MetricManager = class {
|
|
|
8633
8704
|
async flush() {
|
|
8634
8705
|
const lc = this.#lc;
|
|
8635
8706
|
if (this.#timerID === null) {
|
|
8636
|
-
lc.error?.(
|
|
8707
|
+
lc.error?.(
|
|
8708
|
+
on_error_kind_enum_exports.InvalidState,
|
|
8709
|
+
"MetricManager.flush() called but already stopped"
|
|
8710
|
+
);
|
|
8637
8711
|
return;
|
|
8638
8712
|
}
|
|
8639
8713
|
const allSeries = [];
|
|
@@ -8654,12 +8728,15 @@ var MetricManager = class {
|
|
|
8654
8728
|
try {
|
|
8655
8729
|
await this.#reporter(allSeries);
|
|
8656
8730
|
} catch (e) {
|
|
8657
|
-
lc?.error?.(`Error reporting metrics: ${e}`);
|
|
8731
|
+
lc?.error?.(on_error_kind_enum_exports.Metrics, `Error reporting metrics: ${e}`);
|
|
8658
8732
|
}
|
|
8659
8733
|
}
|
|
8660
8734
|
stop() {
|
|
8661
8735
|
if (this.#timerID === null) {
|
|
8662
|
-
this.#lc.error?.(
|
|
8736
|
+
this.#lc.error?.(
|
|
8737
|
+
on_error_kind_enum_exports.InvalidState,
|
|
8738
|
+
"MetricManager.stop() called but already stopped"
|
|
8739
|
+
);
|
|
8663
8740
|
return;
|
|
8664
8741
|
}
|
|
8665
8742
|
clearInterval(this.#timerID);
|
|
@@ -8787,6 +8864,7 @@ var MutationTracker = class {
|
|
|
8787
8864
|
processPushResponse(response) {
|
|
8788
8865
|
if ("error" in response) {
|
|
8789
8866
|
this.#lc.error?.(
|
|
8867
|
+
on_error_kind_enum_exports.Push,
|
|
8790
8868
|
"Received an error response when pushing mutations",
|
|
8791
8869
|
response
|
|
8792
8870
|
);
|
|
@@ -8857,7 +8935,11 @@ var MutationTracker = class {
|
|
|
8857
8935
|
mid.clientID === this.#clientID,
|
|
8858
8936
|
"received mutation for the wrong client"
|
|
8859
8937
|
);
|
|
8860
|
-
this.#lc.error?.(
|
|
8938
|
+
this.#lc.error?.(
|
|
8939
|
+
on_error_kind_enum_exports.Mutation,
|
|
8940
|
+
`Mutation ${mid.id} returned an error`,
|
|
8941
|
+
error
|
|
8942
|
+
);
|
|
8861
8943
|
const ephemeralID = this.#ephemeralIDsByMutationID.get(mid.id);
|
|
8862
8944
|
assert(
|
|
8863
8945
|
ephemeralID,
|
|
@@ -9109,10 +9191,20 @@ var QueryManager = class {
|
|
|
9109
9191
|
}
|
|
9110
9192
|
};
|
|
9111
9193
|
|
|
9194
|
+
// ../zero-client/src/client/options.ts
|
|
9195
|
+
var updateNeededReasonTypeSchema = valita_exports.union(
|
|
9196
|
+
valita_exports.literal(update_needed_reason_type_enum_exports.NewClientGroup),
|
|
9197
|
+
valita_exports.literal(update_needed_reason_type_enum_exports.VersionNotSupported),
|
|
9198
|
+
valita_exports.literal(update_needed_reason_type_enum_exports.SchemaVersionNotSupported)
|
|
9199
|
+
);
|
|
9200
|
+
|
|
9112
9201
|
// ../zero-client/src/client/reload-error-handler.ts
|
|
9113
|
-
import "@rocicorp/logger";
|
|
9114
9202
|
var RELOAD_REASON_STORAGE_KEY = "_zeroReloadReason";
|
|
9115
9203
|
var RELOAD_BACKOFF_STATE_KEY = "_zeroReloadBackoffState";
|
|
9204
|
+
var reloadReasonSchema = valita_exports.tuple([
|
|
9205
|
+
valita_exports.union(updateNeededReasonTypeSchema, errorKindSchema),
|
|
9206
|
+
valita_exports.string()
|
|
9207
|
+
]);
|
|
9116
9208
|
var backoffStateSchema = valita_exports.object({
|
|
9117
9209
|
lastReloadTime: valita_exports.number().default(0),
|
|
9118
9210
|
nextIntervalMs: valita_exports.number().default(0)
|
|
@@ -9121,16 +9213,19 @@ var MIN_RELOAD_INTERVAL_MS = 500;
|
|
|
9121
9213
|
var MAX_RELOAD_INTERVAL_MS = 6e4;
|
|
9122
9214
|
var FALLBACK_RELOAD_INTERVAL_MS = 1e4;
|
|
9123
9215
|
var reloadTimer = null;
|
|
9124
|
-
function reloadWithReason(lc, reload2, reason) {
|
|
9216
|
+
function reloadWithReason(lc, reload2, reason, message) {
|
|
9125
9217
|
if (reloadTimer) {
|
|
9126
|
-
lc.
|
|
9218
|
+
lc.info?.("reload timer already scheduled");
|
|
9127
9219
|
return;
|
|
9128
9220
|
}
|
|
9129
9221
|
const now = Date.now();
|
|
9130
9222
|
const backoff = nextBackoff(lc, now);
|
|
9131
9223
|
if (typeof sessionStorage !== "undefined") {
|
|
9132
9224
|
sessionStorage.setItem(RELOAD_BACKOFF_STATE_KEY, JSON.stringify(backoff));
|
|
9133
|
-
sessionStorage.setItem(
|
|
9225
|
+
sessionStorage.setItem(
|
|
9226
|
+
RELOAD_REASON_STORAGE_KEY,
|
|
9227
|
+
JSON.stringify([reason, message])
|
|
9228
|
+
);
|
|
9134
9229
|
}
|
|
9135
9230
|
const delay = backoff.lastReloadTime - now;
|
|
9136
9231
|
lc.error?.(
|
|
@@ -9146,10 +9241,17 @@ function reloadWithReason(lc, reload2, reason) {
|
|
|
9146
9241
|
}
|
|
9147
9242
|
function reportReloadReason(lc) {
|
|
9148
9243
|
if (typeof sessionStorage !== "undefined") {
|
|
9149
|
-
const
|
|
9150
|
-
if (
|
|
9244
|
+
const value = sessionStorage.getItem(RELOAD_REASON_STORAGE_KEY);
|
|
9245
|
+
if (value) {
|
|
9151
9246
|
sessionStorage.removeItem(RELOAD_REASON_STORAGE_KEY);
|
|
9152
|
-
|
|
9247
|
+
try {
|
|
9248
|
+
const parsed = JSON.parse(value);
|
|
9249
|
+
const [reasonType, message] = parse(parsed, reloadReasonSchema);
|
|
9250
|
+
lc.error?.(reasonType, "Zero reloaded the page.", message);
|
|
9251
|
+
} catch (e) {
|
|
9252
|
+
lc.error?.(on_error_kind_enum_exports.InvalidState, "Zero reloaded the page.", e);
|
|
9253
|
+
return;
|
|
9254
|
+
}
|
|
9153
9255
|
}
|
|
9154
9256
|
}
|
|
9155
9257
|
}
|
|
@@ -9215,14 +9317,14 @@ function isAuthError(ex) {
|
|
|
9215
9317
|
return isServerError(ex) && isAuthErrorKind(ex.kind);
|
|
9216
9318
|
}
|
|
9217
9319
|
function isAuthErrorKind(kind) {
|
|
9218
|
-
return kind === AuthInvalidated || kind === Unauthorized;
|
|
9320
|
+
return kind === error_kind_enum_exports.AuthInvalidated || kind === error_kind_enum_exports.Unauthorized;
|
|
9219
9321
|
}
|
|
9220
9322
|
function isBackoffError(ex) {
|
|
9221
9323
|
if (isServerError(ex)) {
|
|
9222
9324
|
switch (ex.errorBody.kind) {
|
|
9223
|
-
case Rebalance:
|
|
9224
|
-
case Rehome:
|
|
9225
|
-
case ServerOverloaded:
|
|
9325
|
+
case error_kind_enum_exports.Rebalance:
|
|
9326
|
+
case error_kind_enum_exports.Rehome:
|
|
9327
|
+
case error_kind_enum_exports.ServerOverloaded:
|
|
9226
9328
|
return ex.errorBody;
|
|
9227
9329
|
}
|
|
9228
9330
|
}
|
|
@@ -9290,6 +9392,10 @@ function getServer(server) {
|
|
|
9290
9392
|
return validateServerParam("server", server);
|
|
9291
9393
|
}
|
|
9292
9394
|
|
|
9395
|
+
// ../zero-client/src/client/zero-log-context.ts
|
|
9396
|
+
import { LogContext as LogContext3 } from "@rocicorp/logger";
|
|
9397
|
+
var ZeroLogContext = LogContext3;
|
|
9398
|
+
|
|
9293
9399
|
// ../zero-client/src/client/zero-poke-handler.ts
|
|
9294
9400
|
import { Lock as Lock3 } from "@rocicorp/lock";
|
|
9295
9401
|
var PokeHandler = class {
|
|
@@ -9413,7 +9519,11 @@ var PokeHandler = class {
|
|
|
9413
9519
|
if (String(e).includes("unexpected base cookie for poke")) {
|
|
9414
9520
|
this.#lc.debug?.("clearing due to", e);
|
|
9415
9521
|
} else {
|
|
9416
|
-
this.#lc.error?.(
|
|
9522
|
+
this.#lc.error?.(
|
|
9523
|
+
on_error_kind_enum_exports.Poke,
|
|
9524
|
+
"clearing due to unexpected poke error",
|
|
9525
|
+
e
|
|
9526
|
+
);
|
|
9417
9527
|
}
|
|
9418
9528
|
this.#clear();
|
|
9419
9529
|
this.#onPokeError();
|
|
@@ -9633,7 +9743,7 @@ var NULL_LAST_MUTATION_ID_SENT = { clientID: "", id: -1 };
|
|
|
9633
9743
|
function convertOnUpdateNeededReason(reason) {
|
|
9634
9744
|
return { type: reason.type };
|
|
9635
9745
|
}
|
|
9636
|
-
function
|
|
9746
|
+
function updateNeededReloadReasonMessage(reason, serverErrMsg) {
|
|
9637
9747
|
const { type } = reason;
|
|
9638
9748
|
let reasonMsg = "";
|
|
9639
9749
|
switch (type) {
|
|
@@ -9654,9 +9764,7 @@ function updateNeededReloadReason(reason, serverErrMsg) {
|
|
|
9654
9764
|
}
|
|
9655
9765
|
return reasonMsg;
|
|
9656
9766
|
}
|
|
9657
|
-
|
|
9658
|
-
return `Server reported that client is ahead of server (${kind}). This probably happened because the server is in development mode and restarted. Currently when this happens, the dev server loses its state and on reconnect sees the client as ahead. If you see this in other cases, it may be a bug in Zero.`;
|
|
9659
|
-
}
|
|
9767
|
+
var serverAheadReloadReason = `Server reported that client is ahead of server. This probably happened because the server is in development mode and restarted. Currently when this happens, the dev server loses its state and on reconnect sees the client as ahead. If you see this in other cases, it may be a bug in Zero.`;
|
|
9660
9768
|
function onClientStateNotFoundServerReason(serverErrMsg) {
|
|
9661
9769
|
return `Server could not find state needed to synchronize this client. ${serverErrMsg}`;
|
|
9662
9770
|
}
|
|
@@ -9816,7 +9924,21 @@ var Zero = class {
|
|
|
9816
9924
|
`A mutator, or mutator namespace, has already been defined for ${key}`
|
|
9817
9925
|
);
|
|
9818
9926
|
}
|
|
9819
|
-
const
|
|
9927
|
+
const { onError } = options;
|
|
9928
|
+
const sink = logOptions.logSink;
|
|
9929
|
+
const logSink = {
|
|
9930
|
+
log(level, context, ...args) {
|
|
9931
|
+
if (level === "error" && onError) {
|
|
9932
|
+
onError(...args);
|
|
9933
|
+
} else {
|
|
9934
|
+
sink.log(level, context, ...args);
|
|
9935
|
+
}
|
|
9936
|
+
},
|
|
9937
|
+
async flush() {
|
|
9938
|
+
await sink.flush?.();
|
|
9939
|
+
}
|
|
9940
|
+
};
|
|
9941
|
+
const lc = new ZeroLogContext(logOptions.logLevel, {}, logSink);
|
|
9820
9942
|
this.#mutationTracker = new MutationTracker(lc);
|
|
9821
9943
|
if (options.mutators) {
|
|
9822
9944
|
for (const [namespaceOrKey, mutatorOrMutators] of Object.entries(
|
|
@@ -9883,7 +10005,7 @@ var Zero = class {
|
|
|
9883
10005
|
(ast, ttl) => this.#queryManager.update(ast, ttl),
|
|
9884
10006
|
batchViewUpdates,
|
|
9885
10007
|
slowMaterializeThreshold,
|
|
9886
|
-
|
|
10008
|
+
assertValidRunOptions2
|
|
9887
10009
|
);
|
|
9888
10010
|
const replicacheImplOptions = {
|
|
9889
10011
|
enableClientGroupForking: false,
|
|
@@ -9907,13 +10029,18 @@ var Zero = class {
|
|
|
9907
10029
|
this.userID = userID;
|
|
9908
10030
|
this.#lc = lc.withContext("clientID", rep.clientID);
|
|
9909
10031
|
this.#mutationTracker.clientID = rep.clientID;
|
|
9910
|
-
const onUpdateNeededCallback =
|
|
9911
|
-
|
|
9912
|
-
|
|
9913
|
-
|
|
9914
|
-
|
|
9915
|
-
|
|
9916
|
-
|
|
10032
|
+
const onUpdateNeededCallback = (reason, serverErrorMsg) => {
|
|
10033
|
+
if (onUpdateNeeded) {
|
|
10034
|
+
onUpdateNeeded(reason);
|
|
10035
|
+
} else {
|
|
10036
|
+
reloadWithReason(
|
|
10037
|
+
this.#lc,
|
|
10038
|
+
this.#reload,
|
|
10039
|
+
reason.type,
|
|
10040
|
+
updateNeededReloadReasonMessage(reason, serverErrorMsg)
|
|
10041
|
+
);
|
|
10042
|
+
}
|
|
10043
|
+
};
|
|
9917
10044
|
this.#onUpdateNeeded = onUpdateNeededCallback;
|
|
9918
10045
|
this.#rep.onUpdateNeeded = (reason) => {
|
|
9919
10046
|
onUpdateNeededCallback(convertOnUpdateNeededReason(reason));
|
|
@@ -9922,6 +10049,7 @@ var Zero = class {
|
|
|
9922
10049
|
reloadWithReason(
|
|
9923
10050
|
this.#lc,
|
|
9924
10051
|
this.#reload,
|
|
10052
|
+
error_kind_enum_exports.ClientNotFound,
|
|
9925
10053
|
reason ?? ON_CLIENT_STATE_NOT_FOUND_REASON_CLIENT
|
|
9926
10054
|
);
|
|
9927
10055
|
});
|
|
@@ -10193,7 +10321,8 @@ var Zero = class {
|
|
|
10193
10321
|
const l = addWebSocketIDFromSocketToLogContext(this.#socket, this.#lc);
|
|
10194
10322
|
if (this.#connectStart === void 0) {
|
|
10195
10323
|
l.error?.(
|
|
10196
|
-
|
|
10324
|
+
on_error_kind_enum_exports.InvalidState,
|
|
10325
|
+
"Got open event but connect start time is undefined."
|
|
10197
10326
|
);
|
|
10198
10327
|
} else {
|
|
10199
10328
|
const now = Date.now();
|
|
@@ -10205,20 +10334,27 @@ var Zero = class {
|
|
|
10205
10334
|
}
|
|
10206
10335
|
};
|
|
10207
10336
|
#onClose = (e) => {
|
|
10208
|
-
const
|
|
10337
|
+
const lc = addWebSocketIDFromSocketToLogContext(this.#socket, this.#lc);
|
|
10209
10338
|
const { code, reason, wasClean } = e;
|
|
10210
|
-
|
|
10211
|
-
|
|
10339
|
+
if (code <= 1001) {
|
|
10340
|
+
lc.info?.("Got socket close event", { code, reason, wasClean });
|
|
10341
|
+
} else {
|
|
10342
|
+
lc.error?.(on_error_kind_enum_exports.Network, "Got unexpected socket close event", {
|
|
10343
|
+
code,
|
|
10344
|
+
reason,
|
|
10345
|
+
wasClean
|
|
10346
|
+
});
|
|
10347
|
+
}
|
|
10212
10348
|
const closeKind = wasClean ? "CleanClose" : "AbruptClose";
|
|
10213
10349
|
this.#connectResolver.reject(new CloseError(closeKind));
|
|
10214
|
-
this.#disconnect(
|
|
10350
|
+
this.#disconnect(lc, { client: closeKind });
|
|
10215
10351
|
};
|
|
10216
10352
|
// An error on the connection is fatal for the connection.
|
|
10217
10353
|
async #handleErrorMessage(lc, downMessage) {
|
|
10218
10354
|
const [, { kind, message }] = downMessage;
|
|
10219
|
-
if (kind === MutationRateLimited) {
|
|
10355
|
+
if (kind === error_kind_enum_exports.MutationRateLimited) {
|
|
10220
10356
|
this.#lastMutationIDSent = NULL_LAST_MUTATION_ID_SENT;
|
|
10221
|
-
lc.error?.("Mutation rate limited", { message });
|
|
10357
|
+
lc.error?.(kind, "Mutation rate limited", { message });
|
|
10222
10358
|
return;
|
|
10223
10359
|
}
|
|
10224
10360
|
lc.info?.(`${kind}: ${message}}`);
|
|
@@ -10227,17 +10363,17 @@ var Zero = class {
|
|
|
10227
10363
|
lc.debug?.("Rejecting connect resolver due to error", error);
|
|
10228
10364
|
this.#connectResolver.reject(error);
|
|
10229
10365
|
this.#disconnect(lc, { server: kind });
|
|
10230
|
-
if (kind === VersionNotSupported) {
|
|
10366
|
+
if (kind === error_kind_enum_exports.VersionNotSupported) {
|
|
10231
10367
|
this.#onUpdateNeeded?.({ type: kind }, message);
|
|
10232
|
-
} else if (kind === SchemaVersionNotSupported) {
|
|
10368
|
+
} else if (kind === error_kind_enum_exports.SchemaVersionNotSupported) {
|
|
10233
10369
|
await this.#rep.disableClientGroup();
|
|
10234
10370
|
this.#onUpdateNeeded?.({ type: "SchemaVersionNotSupported" }, message);
|
|
10235
|
-
} else if (kind === ClientNotFound) {
|
|
10371
|
+
} else if (kind === error_kind_enum_exports.ClientNotFound) {
|
|
10236
10372
|
await this.#rep.disableClientGroup();
|
|
10237
10373
|
this.#onClientStateNotFound?.(onClientStateNotFoundServerReason(message));
|
|
10238
|
-
} else if (kind === InvalidConnectionRequestLastMutationID || kind === InvalidConnectionRequestBaseCookie) {
|
|
10374
|
+
} else if (kind === error_kind_enum_exports.InvalidConnectionRequestLastMutationID || kind === error_kind_enum_exports.InvalidConnectionRequestBaseCookie) {
|
|
10239
10375
|
await dropDatabase(this.#rep.idbName);
|
|
10240
|
-
reloadWithReason(lc, this.#reload, serverAheadReloadReason
|
|
10376
|
+
reloadWithReason(lc, this.#reload, kind, serverAheadReloadReason);
|
|
10241
10377
|
}
|
|
10242
10378
|
}
|
|
10243
10379
|
async #handleConnectedMessage(lc, connectedMessage) {
|
|
@@ -10258,7 +10394,8 @@ var Zero = class {
|
|
|
10258
10394
|
let connectMsgLatencyMs;
|
|
10259
10395
|
if (this.#connectStart === void 0) {
|
|
10260
10396
|
lc.error?.(
|
|
10261
|
-
|
|
10397
|
+
on_error_kind_enum_exports.InvalidState,
|
|
10398
|
+
"Got connected message but connect start time is undefined."
|
|
10262
10399
|
);
|
|
10263
10400
|
} else {
|
|
10264
10401
|
timeToConnectMs = now - this.#connectStart;
|
|
@@ -10269,7 +10406,8 @@ var Zero = class {
|
|
|
10269
10406
|
let totalTimeToConnectMs;
|
|
10270
10407
|
if (this.#totalToConnectStart === void 0) {
|
|
10271
10408
|
lc.error?.(
|
|
10272
|
-
|
|
10409
|
+
on_error_kind_enum_exports.InvalidState,
|
|
10410
|
+
"Got connected message but total to connect start time is undefined."
|
|
10273
10411
|
);
|
|
10274
10412
|
} else {
|
|
10275
10413
|
totalTimeToConnectMs = now - this.#totalToConnectStart;
|
|
@@ -10341,12 +10479,12 @@ var Zero = class {
|
|
|
10341
10479
|
* is received before the connected message is received or if the connection
|
|
10342
10480
|
* attempt times out.
|
|
10343
10481
|
*/
|
|
10344
|
-
async #connect(
|
|
10482
|
+
async #connect(lc, additionalConnectParams) {
|
|
10345
10483
|
assert(this.#server);
|
|
10346
10484
|
assert(this.#connectionState === Disconnected);
|
|
10347
10485
|
const wsid = nanoid();
|
|
10348
|
-
|
|
10349
|
-
|
|
10486
|
+
lc = addWebSocketIDToLogContext(wsid, lc);
|
|
10487
|
+
lc.info?.("Connecting...", { navigatorOnline: localNavigator?.onLine });
|
|
10350
10488
|
this.#setConnectionState(Connecting);
|
|
10351
10489
|
assert(this.#connectStart === void 0);
|
|
10352
10490
|
const now = Date.now();
|
|
@@ -10365,9 +10503,9 @@ var Zero = class {
|
|
|
10365
10503
|
return;
|
|
10366
10504
|
}
|
|
10367
10505
|
const timeoutID = setTimeout(() => {
|
|
10368
|
-
|
|
10506
|
+
lc.debug?.("Rejecting connect resolver due to timeout");
|
|
10369
10507
|
this.#connectResolver.reject(new TimedOutError("Connect"));
|
|
10370
|
-
this.#disconnect(
|
|
10508
|
+
this.#disconnect(lc, {
|
|
10371
10509
|
client: "ConnectTimeout"
|
|
10372
10510
|
});
|
|
10373
10511
|
}, CONNECT_TIMEOUT_MS);
|
|
@@ -10389,7 +10527,7 @@ var Zero = class {
|
|
|
10389
10527
|
this.#lastMutationIDReceived,
|
|
10390
10528
|
wsid,
|
|
10391
10529
|
this.#options.logLevel === "debug",
|
|
10392
|
-
|
|
10530
|
+
lc,
|
|
10393
10531
|
this.#options.push,
|
|
10394
10532
|
this.#options.maxHeaderLength,
|
|
10395
10533
|
additionalConnectParams
|
|
@@ -10409,7 +10547,7 @@ var Zero = class {
|
|
|
10409
10547
|
this.#onPageHide
|
|
10410
10548
|
);
|
|
10411
10549
|
try {
|
|
10412
|
-
|
|
10550
|
+
lc.debug?.("Waiting for connection to be acknowledged");
|
|
10413
10551
|
await this.#connectResolver.promise;
|
|
10414
10552
|
this.#mutationTracker.onConnected(this.#lastMutationIDReceived);
|
|
10415
10553
|
this.#rep.push().catch(() => {
|
|
@@ -10422,11 +10560,11 @@ var Zero = class {
|
|
|
10422
10560
|
);
|
|
10423
10561
|
}
|
|
10424
10562
|
}
|
|
10425
|
-
#disconnect(
|
|
10563
|
+
#disconnect(lc, reason, closeCode, closeReason) {
|
|
10426
10564
|
if (this.#connectionState === Connecting) {
|
|
10427
10565
|
this.#connectErrorCount++;
|
|
10428
10566
|
}
|
|
10429
|
-
|
|
10567
|
+
lc.info?.("disconnecting", {
|
|
10430
10568
|
navigatorOnline: localNavigator?.onLine,
|
|
10431
10569
|
reason,
|
|
10432
10570
|
connectStart: this.#connectStart,
|
|
@@ -10440,8 +10578,9 @@ var Zero = class {
|
|
|
10440
10578
|
switch (this.#connectionState) {
|
|
10441
10579
|
case Connected: {
|
|
10442
10580
|
if (this.#connectStart !== void 0) {
|
|
10443
|
-
|
|
10444
|
-
|
|
10581
|
+
lc.error?.(
|
|
10582
|
+
on_error_kind_enum_exports.InvalidState,
|
|
10583
|
+
"disconnect() called while connected but connect start time is defined."
|
|
10445
10584
|
);
|
|
10446
10585
|
}
|
|
10447
10586
|
break;
|
|
@@ -10456,18 +10595,22 @@ var Zero = class {
|
|
|
10456
10595
|
);
|
|
10457
10596
|
}
|
|
10458
10597
|
if (this.#connectStart === void 0) {
|
|
10459
|
-
|
|
10460
|
-
|
|
10598
|
+
lc.error?.(
|
|
10599
|
+
on_error_kind_enum_exports.InvalidState,
|
|
10600
|
+
"disconnect() called while connecting but connect start time is undefined."
|
|
10461
10601
|
);
|
|
10462
10602
|
}
|
|
10463
10603
|
break;
|
|
10464
10604
|
}
|
|
10465
10605
|
case Disconnected:
|
|
10466
|
-
|
|
10606
|
+
lc.error?.(
|
|
10607
|
+
on_error_kind_enum_exports.InvalidState,
|
|
10608
|
+
"disconnect() called while disconnected"
|
|
10609
|
+
);
|
|
10467
10610
|
break;
|
|
10468
10611
|
}
|
|
10469
10612
|
this.#socketResolver = resolver8();
|
|
10470
|
-
|
|
10613
|
+
lc.debug?.("Creating new connect resolver");
|
|
10471
10614
|
this.#connectResolver = resolver8();
|
|
10472
10615
|
this.#setConnectionState(Disconnected);
|
|
10473
10616
|
this.#messageCount = 0;
|
|
@@ -10645,7 +10788,7 @@ var Zero = class {
|
|
|
10645
10788
|
break;
|
|
10646
10789
|
}
|
|
10647
10790
|
case Connecting:
|
|
10648
|
-
lc.error?.(
|
|
10791
|
+
lc.error?.(on_error_kind_enum_exports.InvalidState);
|
|
10649
10792
|
gotError = true;
|
|
10650
10793
|
break;
|
|
10651
10794
|
case Connected: {
|
|
@@ -10693,7 +10836,8 @@ var Zero = class {
|
|
|
10693
10836
|
} catch (ex) {
|
|
10694
10837
|
if (this.#connectionState !== Connected) {
|
|
10695
10838
|
const level = isAuthError(ex) ? "warn" : "error";
|
|
10696
|
-
|
|
10839
|
+
const kind = isServerError(ex) ? ex.kind : on_error_kind_enum_exports.Unknown;
|
|
10840
|
+
lc[level]?.(kind, "Failed to connect", ex, {
|
|
10697
10841
|
lmid: this.#lastMutationIDReceived,
|
|
10698
10842
|
baseCookie: this.#connectCookie
|
|
10699
10843
|
});
|
|
@@ -10793,7 +10937,7 @@ var Zero = class {
|
|
|
10793
10937
|
};
|
|
10794
10938
|
}
|
|
10795
10939
|
default:
|
|
10796
|
-
|
|
10940
|
+
unreachable();
|
|
10797
10941
|
}
|
|
10798
10942
|
} finally {
|
|
10799
10943
|
pullResponseResolver.reject("timed out");
|
|
@@ -10820,8 +10964,8 @@ var Zero = class {
|
|
|
10820
10964
|
* If it takes too long to get a pong we disconnect and this returns
|
|
10821
10965
|
* {@linkcode PingResult.TimedOut}.
|
|
10822
10966
|
*/
|
|
10823
|
-
async #ping(
|
|
10824
|
-
|
|
10967
|
+
async #ping(lc, messageErrorRejectionPromise) {
|
|
10968
|
+
lc.debug?.("pinging");
|
|
10825
10969
|
const { promise, resolve } = resolver8();
|
|
10826
10970
|
this.#onPong = resolve;
|
|
10827
10971
|
const pingMessage = ["ping", {}];
|
|
@@ -10835,13 +10979,13 @@ var Zero = class {
|
|
|
10835
10979
|
]) === 0;
|
|
10836
10980
|
const delta = performance.now() - t0;
|
|
10837
10981
|
if (!connected) {
|
|
10838
|
-
|
|
10839
|
-
this.#disconnect(
|
|
10982
|
+
lc.info?.("ping failed in", delta, "ms - disconnecting");
|
|
10983
|
+
this.#disconnect(lc, {
|
|
10840
10984
|
client: "PingTimeout"
|
|
10841
10985
|
});
|
|
10842
10986
|
return TimedOut;
|
|
10843
10987
|
}
|
|
10844
|
-
|
|
10988
|
+
lc.debug?.("ping succeeded in", delta, "ms");
|
|
10845
10989
|
return Success;
|
|
10846
10990
|
}
|
|
10847
10991
|
// Sends a set of metrics to the server. Throws unless the server
|
|
@@ -10868,8 +11012,11 @@ var Zero = class {
|
|
|
10868
11012
|
*/
|
|
10869
11013
|
async inspect() {
|
|
10870
11014
|
BUNDLE_SIZE: {
|
|
10871
|
-
const m = await import("./inspector-
|
|
10872
|
-
return m.newInspector(this.#rep, this.#schema, () =>
|
|
11015
|
+
const m = await import("./inspector-T4TQPT2K.js");
|
|
11016
|
+
return m.newInspector(this.#rep, this.#schema, async () => {
|
|
11017
|
+
await this.#connectResolver.promise;
|
|
11018
|
+
return this.#socket;
|
|
11019
|
+
});
|
|
10873
11020
|
}
|
|
10874
11021
|
}
|
|
10875
11022
|
};
|
|
@@ -10965,8 +11112,7 @@ var TimedOutError = class extends Error {
|
|
|
10965
11112
|
};
|
|
10966
11113
|
var CloseError = class extends Error {
|
|
10967
11114
|
};
|
|
10968
|
-
function
|
|
10969
|
-
return options ?? DEFAULT_RUN_OPTIONS_UNKNOWN;
|
|
11115
|
+
function assertValidRunOptions2(_options) {
|
|
10970
11116
|
}
|
|
10971
11117
|
|
|
10972
11118
|
export {
|
|
@@ -10976,6 +11122,7 @@ export {
|
|
|
10976
11122
|
makeIDBName,
|
|
10977
11123
|
dropDatabase,
|
|
10978
11124
|
dropAllDatabases,
|
|
11125
|
+
error_kind_enum_exports,
|
|
10979
11126
|
relationships,
|
|
10980
11127
|
table,
|
|
10981
11128
|
string3 as string,
|
|
@@ -10989,6 +11136,8 @@ export {
|
|
|
10989
11136
|
NOBODY_CAN,
|
|
10990
11137
|
definePermissions,
|
|
10991
11138
|
escapeLike,
|
|
11139
|
+
update_needed_reason_type_enum_exports,
|
|
11140
|
+
on_error_kind_enum_exports,
|
|
10992
11141
|
Zero
|
|
10993
11142
|
};
|
|
10994
|
-
//# sourceMappingURL=chunk-
|
|
11143
|
+
//# sourceMappingURL=chunk-ZEL4YSUP.js.map
|