@shaxpir/duiduidui-models 1.9.2 → 1.9.3

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.
@@ -157,14 +157,12 @@ class ShareSync {
157
157
  }
158
158
  createConnectionWithDurableStore(socket, options) {
159
159
  const shareSync = this;
160
- // Create a wrapper callback that ensures it's called exactly once
161
- // The callback should fire when DurableStore is ready, regardless of socket state
162
- // This enables offline-first operation where local data is available immediately
160
+ // Create a wrapper callback that ensures it's called even when offline
163
161
  let readyCallbackInvoked = false;
164
162
  const wrappedCallback = options.onReadyCallback ? function () {
165
163
  if (!readyCallbackInvoked) {
166
164
  readyCallbackInvoked = true;
167
- shareSync._debug && console.log('[ShareSync] DurableStore ready, invoking onReadyCallback (socket open:', shareSync._socketIsOpen, ')');
165
+ shareSync._debug && console.log('[ShareSync] DurableStore ready, invoking onReadyCallback');
168
166
  options.onReadyCallback();
169
167
  }
170
168
  } : undefined;
@@ -185,16 +183,15 @@ class ShareSync {
185
183
  onReadyCallback: wrappedCallback
186
184
  }
187
185
  });
188
- // The DurableStore's 'ready' event fires when local storage initialization completes.
189
- // This happens regardless of socket/network state, enabling offline-first operation.
190
- // Add a safety timeout in case storage initialization hangs (should never happen).
191
- if (wrappedCallback) {
186
+ // Add a fallback timeout to ensure the callback fires even if the DurableStore
187
+ // ready event doesn't properly trigger when offline
188
+ if (wrappedCallback && !shareSync._socketIsOpen) {
192
189
  setTimeout(function () {
193
190
  if (!readyCallbackInvoked) {
194
- console.warn('[ShareSync] DurableStore ready timeout - forcing callback after 5s');
191
+ console.warn('[ShareSync] Socket offline - forcing onReadyCallback after timeout');
195
192
  wrappedCallback();
196
193
  }
197
- }, 5000); // 5 second safety timeout
194
+ }, 100); // Small delay to allow normal initialization first
198
195
  }
199
196
  return connection;
200
197
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shaxpir/duiduidui-models",
3
- "version": "1.9.2",
3
+ "version": "1.9.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/shaxpir/duiduidui-models"