@runner-ai/vite-uuid-tagger 0.0.6 → 0.0.7

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 +11 -9
  2. package/package.json +4 -3
package/dist/index.js CHANGED
@@ -142,7 +142,7 @@ function isInlineEditable(jsxElement) {
142
142
 
143
143
  // src/uuid-mapping-manager.ts
144
144
  import { createHash } from "crypto";
145
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
145
+ import { existsSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "fs";
146
146
  import { dirname, join } from "path";
147
147
  var UUIDMappingManager = class {
148
148
  mappingFile;
@@ -162,24 +162,26 @@ var UUIDMappingManager = class {
162
162
  return {};
163
163
  }
164
164
  saveMappings() {
165
+ const tmpFile = `${this.mappingFile}.${process.pid}.tmp`;
165
166
  try {
166
167
  const dir = dirname(this.mappingFile);
167
168
  if (!existsSync(dir)) {
168
169
  mkdirSync(dir, { recursive: true });
169
170
  }
170
- writeFileSync(this.mappingFile, JSON.stringify(this.mappings, null, 2));
171
+ writeFileSync(tmpFile, JSON.stringify(this.mappings, null, 2));
172
+ renameSync(tmpFile, this.mappingFile);
171
173
  } catch {
174
+ try {
175
+ if (existsSync(tmpFile)) {
176
+ unlinkSync(tmpFile);
177
+ }
178
+ } catch {
179
+ }
172
180
  }
173
181
  }
174
182
  generateStableUUID(seed) {
175
183
  const hash = createHash("sha256").update(seed).digest("hex");
176
- return [
177
- hash.substring(0, 8),
178
- hash.substring(8, 12),
179
- hash.substring(12, 16),
180
- hash.substring(16, 20),
181
- hash.substring(20, 32)
182
- ].join("-");
184
+ return [hash.slice(0, 8), hash.slice(8, 12), hash.slice(12, 16), hash.slice(16, 20), hash.slice(20, 32)].join("-");
183
185
  }
184
186
  getOrCreateUUID(filePath, line, column, elementName) {
185
187
  const existingUUID = Object.keys(this.mappings).find((uuid2) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runner-ai/vite-uuid-tagger",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -27,9 +27,10 @@
27
27
  "vite": ">=4.0.0"
28
28
  },
29
29
  "devDependencies": {
30
+ "@vitest/coverage-v8": "^4.1.2",
30
31
  "tsup": "^8.0.0",
31
32
  "vite": "^7.0.0",
32
- "vitest": "^3.0.0",
33
- "typescript": "^5.8.0"
33
+ "typescript": "^5.8.0",
34
+ "vitest": "^4.1.2"
34
35
  }
35
36
  }