latex-stickies 1.3.1 → 1.3.2

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.
@@ -21,6 +21,16 @@ try {
21
21
  process.exit(1);
22
22
  }
23
23
 
24
+ // Name the Electron shell before launching it, not only at install time.
25
+ // postinstall scripts are increasingly blocked -- npm warns about them by
26
+ // default now, and plenty of people and companies set ignore-scripts -- and a
27
+ // user who installs with them off gets "Electron" in their Dock. Doing it here
28
+ // as well means the name is right by the time macOS reads the bundle, whatever
29
+ // happened during the install. It returns immediately once done.
30
+ try {
31
+ require('../scripts/brand-electron.js');
32
+ } catch (_) { /* cosmetic: never block a launch over the name */ }
33
+
24
34
  const appDir = path.join(__dirname, '..');
25
35
  const child = spawn(electron, [appDir, ...process.argv.slice(2)], {
26
36
  detached: true,
package/build/icon.icns CHANGED
Binary file
package/build/icon.png CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "latex-stickies",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "Sticky notes for your desktop that render LaTeX and Markdown.",
5
5
  "main": "src/main.js",
6
6
  "scripts": {
package/src/store.js CHANGED
@@ -173,15 +173,10 @@ function writeIndex(meta) {
173
173
  }
174
174
  }
175
175
 
176
- function flush() {
177
- timer = null;
176
+ /** The sidecar index alone: filenames to ids, colours, bounds. */
177
+ function flushIndex() {
178
178
  const meta = {};
179
179
  for (const note of all()) {
180
- try {
181
- writeFileAtomic(path.join(DIR, note.file), note.body || '');
182
- } catch (err) {
183
- console.error(`failed to save ${note.file}`, err);
184
- }
185
180
  meta[note.file] = {
186
181
  id: note.id,
187
182
  color: note.color,
@@ -193,6 +188,18 @@ function flush() {
193
188
  writeIndex(meta);
194
189
  }
195
190
 
191
+ function flush() {
192
+ timer = null;
193
+ for (const note of all()) {
194
+ try {
195
+ writeFileAtomic(path.join(DIR, note.file), note.body || '');
196
+ } catch (err) {
197
+ console.error(`failed to save ${note.file}`, err);
198
+ }
199
+ }
200
+ flushIndex();
201
+ }
202
+
196
203
  // Writes are frequent (every keystroke, every window drag), so coalesce them.
197
204
  function save() {
198
205
  if (timer) return;
@@ -234,8 +241,23 @@ function upsert(note) {
234
241
  const next = slugFor(list[i].body, taken, path.extname(before.file) || '.md');
235
242
  try {
236
243
  const from = path.join(DIR, before.file);
244
+ // Both names count as our own writing, or the rename looks like an
245
+ // outside edit and the watcher reloads over the top of it.
246
+ justWrote.set(before.file, Date.now());
247
+ justWrote.set(next, Date.now());
237
248
  if (fs.existsSync(from)) fs.renameSync(from, path.join(DIR, next));
238
249
  list[i].file = next;
250
+ // Write this note's body now too. The rename is immediate but the body
251
+ // is on the 400ms timer, so a reload in between would read the new file
252
+ // and find the old text -- after which the filename stops following the
253
+ // title, because it no longer looks like a name we chose.
254
+ writeFileAtomic(path.join(DIR, next), list[i].body || '');
255
+ // The index must follow the rename at once, not on the 400ms timer.
256
+ // A note's id lives in the index, keyed by filename; anything that
257
+ // reloads in the gap finds a file the index has never heard of, gives
258
+ // it a fresh id, and orphans the window still holding the old one --
259
+ // whose next keystroke then writes a second copy of the same note.
260
+ flushIndex();
239
261
  } catch (err) {
240
262
  console.error(`could not rename ${before.file} to ${next}`, err);
241
263
  }