svelte-realtime 0.4.10 → 0.4.12

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.
Files changed (3) hide show
  1. package/client.js +4 -3
  2. package/package.json +1 -1
  3. package/server.js +2 -2
package/client.js CHANGED
@@ -526,8 +526,6 @@ function _createStream(path, options, dynamicArgs) {
526
526
  let subCount = 0;
527
527
  let pendingId = null;
528
528
 
529
- /** @type {boolean} */
530
- let _hydrated = false;
531
529
 
532
530
  /** @type {number | null} Last known sequence number for replay */
533
531
  let _lastSeq = null;
@@ -928,6 +926,10 @@ function _createStream(path, options, dynamicArgs) {
928
926
  for (const evt of response.data) {
929
927
  _applyMerge(evt);
930
928
  }
929
+ } else if (response.channel && currentValue !== undefined) {
930
+ // Channel fast-path returns an empty placeholder (null or []).
931
+ // Keep the existing value (hydrated SSR data or previously
932
+ // accumulated events) so the store never flashes to empty.
931
933
  } else {
932
934
  currentValue = response.data;
933
935
  }
@@ -1223,7 +1225,6 @@ function _createStream(path, options, dynamicArgs) {
1223
1225
  currentValue = initialData;
1224
1226
  _rebuildIndex();
1225
1227
  store.set(currentValue);
1226
- _hydrated = true;
1227
1228
  return this;
1228
1229
  },
1229
1230
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-realtime",
3
- "version": "0.4.10",
3
+ "version": "0.4.12",
4
4
  "description": "Realtime RPC and reactive subscriptions for SvelteKit, built on svelte-adapter-uws",
5
5
  "author": "Kevin Radziszewski",
6
6
  "license": "MIT",
package/server.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // @ts-check
2
2
 
3
3
  const textDecoder = new TextDecoder();
4
- const _validPathRe = /^[a-zA-Z0-9_]+(?:\/[a-zA-Z0-9_]+)+$/;
4
+ const _validPathRe = /^[a-zA-Z0-9_-]+(?:\/[a-zA-Z0-9_-]+)+$/;
5
5
  const _validSegmentRe = /^[a-zA-Z0-9_]+$/;
6
6
 
7
7
  /** @type {Map<string, Function>} */
@@ -2102,7 +2102,7 @@ async function _executeSingleRpc(ws, msg, platform, options) {
2102
2102
  // Channel fast-path
2103
2103
  if (/** @type {any} */ (fn).__isChannel) {
2104
2104
  const emptyValue = streamOpts.merge === 'set' ? null : [];
2105
- return { id, ok: true, data: emptyValue, topic, merge: streamOpts.merge, key: streamOpts.key, max: streamOpts.max };
2105
+ return { id, ok: true, data: emptyValue, topic, merge: streamOpts.merge, key: streamOpts.key, max: streamOpts.max, channel: true };
2106
2106
  }
2107
2107
 
2108
2108
  // Delta sync