ahmed-rivet-convex 2.0.0 → 2.1.0
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.
|
@@ -14203,6 +14203,17 @@ var ZeroContext = class {
|
|
|
14203
14203
|
#mainSources;
|
|
14204
14204
|
addServerQuery;
|
|
14205
14205
|
addCustomQuery;
|
|
14206
|
+
// ── Local-hydration "got" latch (Convex fork) ─────────────────────
|
|
14207
|
+
// Upstream resolves a query to "complete" when the zero-cache server
|
|
14208
|
+
// acks it (gotQueriesPatch). This fork syncs through the Convex
|
|
14209
|
+
// adapter — there is no zero-cache, so the ack NEVER arrives and
|
|
14210
|
+
// every query reported resultType "unknown" forever (apps could not
|
|
14211
|
+
// gate readiness on it; measured 2026-08-13). Semantics here:
|
|
14212
|
+
// "complete" = the local Replicache hydration has finished
|
|
14213
|
+
// (ZeroRep.init → markLocalHydrationComplete) — the query reflects
|
|
14214
|
+
// local state, which is all "complete" can mean on this stack.
|
|
14215
|
+
#localHydrationDone = false;
|
|
14216
|
+
#pendingGotCallbacks = /* @__PURE__ */ new Set();
|
|
14206
14217
|
updateServerQuery;
|
|
14207
14218
|
updateCustomQuery;
|
|
14208
14219
|
flushQueryChanges;
|
|
@@ -14218,16 +14229,40 @@ var ZeroContext = class {
|
|
|
14218
14229
|
addMetric;
|
|
14219
14230
|
constructor(lc, mainSources, addQuery, addCustomQuery, updateQuery, updateCustomQuery, flushQueryChanges, batchViewUpdates, addMetric, assertValidRunOptions3) {
|
|
14220
14231
|
this.#mainSources = mainSources;
|
|
14221
|
-
|
|
14232
|
+
const wrapGot = (gotCallback) => {
|
|
14233
|
+
if (!gotCallback) return gotCallback;
|
|
14234
|
+
let real = false;
|
|
14235
|
+
const emit = (error) => gotCallback(real || this.#localHydrationDone, error);
|
|
14236
|
+
const wrapped = (got, error) => {
|
|
14237
|
+
real = got;
|
|
14238
|
+
emit(error);
|
|
14239
|
+
};
|
|
14240
|
+
if (this.#localHydrationDone) {
|
|
14241
|
+
void Promise.resolve().then(() => emit());
|
|
14242
|
+
} else {
|
|
14243
|
+
this.#pendingGotCallbacks.add(() => emit());
|
|
14244
|
+
}
|
|
14245
|
+
return wrapped;
|
|
14246
|
+
};
|
|
14247
|
+
this.addServerQuery = (ast, ttl, gotCallback) => addQuery(ast, ttl, wrapGot(gotCallback));
|
|
14248
|
+
this.addCustomQuery = (ast, customQueryID, ttl, gotCallback) => addCustomQuery(ast, customQueryID, ttl, wrapGot(gotCallback));
|
|
14222
14249
|
this.updateServerQuery = updateQuery;
|
|
14223
14250
|
this.updateCustomQuery = updateCustomQuery;
|
|
14224
14251
|
this.#batchViewUpdates = batchViewUpdates;
|
|
14225
14252
|
this.#lc = lc;
|
|
14226
14253
|
this.assertValidRunOptions = assertValidRunOptions3;
|
|
14227
|
-
this.addCustomQuery = addCustomQuery;
|
|
14228
14254
|
this.flushQueryChanges = flushQueryChanges;
|
|
14229
14255
|
this.addMetric = addMetric;
|
|
14230
14256
|
}
|
|
14257
|
+
/** Convex fork: local hydration finished — resolve every mounted and
|
|
14258
|
+
* future query to "complete" (see the latch comment above). */
|
|
14259
|
+
markLocalHydrationComplete() {
|
|
14260
|
+
if (this.#localHydrationDone) return;
|
|
14261
|
+
this.#localHydrationDone = true;
|
|
14262
|
+
const pending = [...this.#pendingGotCallbacks];
|
|
14263
|
+
this.#pendingGotCallbacks.clear();
|
|
14264
|
+
for (const cb of pending) cb(true);
|
|
14265
|
+
}
|
|
14231
14266
|
getSource(name) {
|
|
14232
14267
|
return this.#mainSources.getSource(name);
|
|
14233
14268
|
}
|
|
@@ -14400,19 +14435,20 @@ function makeBatchCRUDMutate(tableName, schema, ops) {
|
|
|
14400
14435
|
}
|
|
14401
14436
|
function makeCRUDMutator(schema) {
|
|
14402
14437
|
return async function zeroCRUDMutator(tx, crudArg) {
|
|
14438
|
+
const ivmBranch = tx[zeroData]?.ivmSources;
|
|
14403
14439
|
for (const op of crudArg.ops) {
|
|
14404
14440
|
switch (op.op) {
|
|
14405
14441
|
case "insert":
|
|
14406
|
-
await insertImpl(tx, op, schema,
|
|
14442
|
+
await insertImpl(tx, op, schema, ivmBranch);
|
|
14407
14443
|
break;
|
|
14408
14444
|
case "upsert":
|
|
14409
|
-
await upsertImpl(tx, op, schema,
|
|
14445
|
+
await upsertImpl(tx, op, schema, ivmBranch);
|
|
14410
14446
|
break;
|
|
14411
14447
|
case "update":
|
|
14412
|
-
await updateImpl(tx, op, schema,
|
|
14448
|
+
await updateImpl(tx, op, schema, ivmBranch);
|
|
14413
14449
|
break;
|
|
14414
14450
|
case "delete":
|
|
14415
|
-
await deleteImpl(tx, op, schema,
|
|
14451
|
+
await deleteImpl(tx, op, schema, ivmBranch);
|
|
14416
14452
|
break;
|
|
14417
14453
|
}
|
|
14418
14454
|
}
|
|
@@ -14939,7 +14975,7 @@ function makeMessage(message, context, logLevel) {
|
|
|
14939
14975
|
}
|
|
14940
14976
|
|
|
14941
14977
|
// ../zero-client/src/client/version.ts
|
|
14942
|
-
var version2 = "2.
|
|
14978
|
+
var version2 = "2.1.0";
|
|
14943
14979
|
|
|
14944
14980
|
// ../zero-client/src/client/log-options.ts
|
|
14945
14981
|
var LevelFilterLogSink = class {
|
|
@@ -16391,6 +16427,7 @@ var ZeroRep = class {
|
|
|
16391
16427
|
logColdIdbStage("init-done", { ms: ts(), entities: diffs.length });
|
|
16392
16428
|
}
|
|
16393
16429
|
console.log(`[ZERO-INIT] done at +${ts()}ms`);
|
|
16430
|
+
this.#context.markLocalHydrationComplete();
|
|
16394
16431
|
}
|
|
16395
16432
|
getTxData = (desiredHead, readOptions) => {
|
|
16396
16433
|
if (!this.#customMutatorsEnabled) {
|
|
@@ -17985,4 +18022,4 @@ export {
|
|
|
17985
18022
|
pako/dist/pako.esm.mjs:
|
|
17986
18023
|
(*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) *)
|
|
17987
18024
|
*/
|
|
17988
|
-
//# sourceMappingURL=chunk-
|
|
18025
|
+
//# sourceMappingURL=chunk-PRRVF77E.js.map
|