@runner-ai/vite-uuid-tagger 0.0.5 → 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.
package/dist/index.d.ts CHANGED
@@ -2,8 +2,6 @@ import { Plugin } from 'vite';
2
2
 
3
3
  interface UuidTaggerOptions {
4
4
  projectRoot: string;
5
- /** Env var name for @runner-ai/design script tag version. Default: VITE_DESIGN_SCRIPT_TAG */
6
- scriptTagEnvVar?: string;
7
5
  }
8
6
  declare function uuidTagger(options: UuidTaggerOptions): Plugin;
9
7
 
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) => {
@@ -205,7 +207,7 @@ var UUIDMappingManager = class {
205
207
 
206
208
  // src/plugin.ts
207
209
  function uuidTagger(options) {
208
- const { projectRoot, scriptTagEnvVar = "VITE_DESIGN_SCRIPT_TAG" } = options;
210
+ const { projectRoot } = options;
209
211
  const uuidManager = new UUIDMappingManager(projectRoot);
210
212
  return {
211
213
  name: "vite-uuid-tagger",
@@ -260,11 +262,6 @@ function uuidTagger(options) {
260
262
  } catch {
261
263
  return null;
262
264
  }
263
- },
264
- transformIndexHtml(html) {
265
- const tag = process.env[scriptTagEnvVar];
266
- const src = `https://unpkg.com/@runner-ai/design${tag ? `@${tag}` : ""}`;
267
- return html.replace("</body>", `<script src="${src}"></script></body>`);
268
265
  }
269
266
  };
270
267
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runner-ai/vite-uuid-tagger",
3
- "version": "0.0.5",
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
  }