svelte-realtime 0.5.0 → 0.5.2
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/client.js +29 -1
- package/package.json +1 -1
- package/server.js +2 -2
package/client.js
CHANGED
|
@@ -2562,6 +2562,23 @@ function _createStream(path, options, dynamicArgs, initialSchemaVersion) {
|
|
|
2562
2562
|
_history = [];
|
|
2563
2563
|
_historyIndex = -1;
|
|
2564
2564
|
_reconnectAttempts = 0;
|
|
2565
|
+
// Reset session-resume cursors. Cleanup means the stream is being
|
|
2566
|
+
// abandoned (last subscriber gone, deferred-cleanup microtask fired);
|
|
2567
|
+
// the next subscribe must start fresh, not falsely resume from
|
|
2568
|
+
// whatever seq / version / cursor the prior session left behind.
|
|
2569
|
+
// Without these resets, an unmount/remount cycle (e.g. browser back
|
|
2570
|
+
// then forward) sends a stale `seq` to the server, the server
|
|
2571
|
+
// responds with a since-seq delta (often empty), and the client's
|
|
2572
|
+
// reset `currentValue = undefined` never gets repopulated -- the
|
|
2573
|
+
// store stays undefined and any `{#if $store === undefined}` spinner
|
|
2574
|
+
// hangs forever. In-session WS reconnects do NOT go through cleanup,
|
|
2575
|
+
// so the replay-buffer gap-fill optimization is preserved for those.
|
|
2576
|
+
_lastSeq = null;
|
|
2577
|
+
_lastVersion = undefined;
|
|
2578
|
+
_schemaVersion = initialSchemaVersion;
|
|
2579
|
+
_cursor = null;
|
|
2580
|
+
_hasMore = false;
|
|
2581
|
+
_loadingMore = false;
|
|
2565
2582
|
_devtoolsStream(path, null, 0, merge);
|
|
2566
2583
|
}
|
|
2567
2584
|
|
|
@@ -2784,7 +2801,18 @@ function _createStream(path, options, dynamicArgs, initialSchemaVersion) {
|
|
|
2784
2801
|
}
|
|
2785
2802
|
|
|
2786
2803
|
if (_optimisticQueue.length === 0) {
|
|
2787
|
-
|
|
2804
|
+
// Default to [] for array-merge types when the loader has not
|
|
2805
|
+
// resolved yet (currentValue still undefined). Without this,
|
|
2806
|
+
// an early-click optimistic change that does e.g.
|
|
2807
|
+
// `(current) => [...current, item]` throws synchronously on
|
|
2808
|
+
// `[...undefined]`, the mutate rejects, and the user sees
|
|
2809
|
+
// nothing land. The eventual loader response replaces
|
|
2810
|
+
// currentValue cleanly via the response path, and the still-
|
|
2811
|
+
// in-flight optimistic entry replays against the new
|
|
2812
|
+
// _serverValue when the server's confirming event arrives.
|
|
2813
|
+
const isArrayMerge = merge === 'crud' || merge === 'presence' || merge === 'cursor' || merge === 'latest';
|
|
2814
|
+
const baseline = currentValue === undefined && isArrayMerge ? [] : currentValue;
|
|
2815
|
+
_serverValue = Array.isArray(baseline) ? baseline.slice() : baseline;
|
|
2788
2816
|
_serverIndex = new Map(_index);
|
|
2789
2817
|
}
|
|
2790
2818
|
const entry = { change: optimisticChange, optimisticKey, serverConfirmed: false };
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -5986,12 +5986,12 @@ live.webhook = function webhook(topic, config) {
|
|
|
5986
5986
|
async handle(req) {
|
|
5987
5987
|
let event;
|
|
5988
5988
|
try {
|
|
5989
|
-
event = config.verify({ body: req.body, headers: req.headers });
|
|
5989
|
+
event = await config.verify({ body: req.body, headers: req.headers });
|
|
5990
5990
|
} catch {
|
|
5991
5991
|
return { status: 400, body: 'Verification failed' };
|
|
5992
5992
|
}
|
|
5993
5993
|
|
|
5994
|
-
const mapped = config.transform(event);
|
|
5994
|
+
const mapped = await config.transform(event);
|
|
5995
5995
|
if (!mapped) return { status: 200, body: 'Ignored' };
|
|
5996
5996
|
|
|
5997
5997
|
if (req.platform) {
|