svelte-realtime 0.5.1 → 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 +12 -1
- package/package.json +1 -1
- package/server.js +2 -2
package/client.js
CHANGED
|
@@ -2801,7 +2801,18 @@ function _createStream(path, options, dynamicArgs, initialSchemaVersion) {
|
|
|
2801
2801
|
}
|
|
2802
2802
|
|
|
2803
2803
|
if (_optimisticQueue.length === 0) {
|
|
2804
|
-
|
|
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;
|
|
2805
2816
|
_serverIndex = new Map(_index);
|
|
2806
2817
|
}
|
|
2807
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) {
|