pencil-team 0.2.1 → 0.2.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.
Files changed (2) hide show
  1. package/dist/index.js +10 -11
  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() {
@@ -9605,12 +9609,7 @@ Shutting down...`);
9605
9609
  sync.disconnect();
9606
9610
  console.log("Closing Pencil...");
9607
9611
  closePencil();
9608
- try {
9609
- if (fs4.existsSync(filePath)) {
9610
- fs4.unlinkSync(filePath);
9611
- console.log("Cleaned up temp file.");
9612
- }
9613
- } catch {}
9612
+ console.log(`File saved: ${filePath}`);
9614
9613
  process.exit(0);
9615
9614
  };
9616
9615
  process.on("SIGINT", shutdown);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pencil-team",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "pencil-team": "dist/index.js"