pencil-team 0.2.2 → 0.2.4

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 (2) hide show
  1. package/dist/index.js +17 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -9262,16 +9262,20 @@ class PenSync {
9262
9262
  debounceTimer = null;
9263
9263
  reconnectTimer = null;
9264
9264
  connected = false;
9265
+ initialSyncDone = false;
9265
9266
  constructor(options) {
9266
9267
  this.options = options;
9267
9268
  this.doc = new Doc;
9268
9269
  this.awareness = new Awareness(this.doc);
9269
- this.loadLocalFile();
9270
- this.setupFileWatcher();
9270
+ this.initialSyncDone = false;
9271
9271
  this.doc.on("update", (update, origin) => {
9272
- if (origin !== "remote")
9273
- return;
9274
- this.writeLocalFile();
9272
+ if (origin === "remote") {
9273
+ this.writeLocalFile();
9274
+ if (!this.initialSyncDone) {
9275
+ this.initialSyncDone = true;
9276
+ this.setupFileWatcher();
9277
+ }
9278
+ }
9275
9279
  });
9276
9280
  }
9277
9281
  loadLocalFile() {
@@ -9383,7 +9387,14 @@ class PenSync {
9383
9387
  platform: getPlatform(),
9384
9388
  selectedNodes: []
9385
9389
  });
9386
- this.options.onConnected?.();
9390
+ setTimeout(() => {
9391
+ this.writeLocalFile();
9392
+ if (!this.initialSyncDone) {
9393
+ this.initialSyncDone = true;
9394
+ this.setupFileWatcher();
9395
+ }
9396
+ this.options.onConnected?.();
9397
+ }, 2000);
9387
9398
  });
9388
9399
  this.ws.on("message", (data) => {
9389
9400
  const message = new Uint8Array(data);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pencil-team",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "pencil-team": "dist/index.js"