@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.
- package/dist/repo/ShareSync.js +7 -10
- package/package.json +1 -1
package/dist/repo/ShareSync.js
CHANGED
|
@@ -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
|
|
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
|
|
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
|
-
//
|
|
189
|
-
//
|
|
190
|
-
|
|
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]
|
|
191
|
+
console.warn('[ShareSync] Socket offline - forcing onReadyCallback after timeout');
|
|
195
192
|
wrappedCallback();
|
|
196
193
|
}
|
|
197
|
-
},
|
|
194
|
+
}, 100); // Small delay to allow normal initialization first
|
|
198
195
|
}
|
|
199
196
|
return connection;
|
|
200
197
|
}
|