uivisor 0.1.0

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.
@@ -0,0 +1,13 @@
1
+ import { Plugin } from 'vite';
2
+
3
+ interface UivisorOptions {
4
+ /** Files to annotate with source locations. Default: /\.[jt]sx$/ */
5
+ include?: RegExp;
6
+ /** Custom data attribute name. Default: "data-uiv-src" */
7
+ attr?: string;
8
+ /** Force-enable outside dev (not recommended). Default: dev only. */
9
+ force?: boolean;
10
+ }
11
+ declare function uivisor(options?: UivisorOptions): Plugin;
12
+
13
+ export { type UivisorOptions, uivisor as default };
@@ -0,0 +1,80 @@
1
+ import {
2
+ uivisorBabel
3
+ } from "../chunk-4XKGGP26.js";
4
+
5
+ // src/vite/index.ts
6
+ import { transformSync } from "@babel/core";
7
+ var warned = false;
8
+ function warnOrder() {
9
+ if (warned) return;
10
+ warned = true;
11
+ console.warn(
12
+ "\n[uivisor] Source locations are disabled because another plugin transformed JSX first.\n[uivisor] Place uivisor() BEFORE react() in your Vite `plugins` array:\n[uivisor] plugins: [uivisor(), react()]\n"
13
+ );
14
+ }
15
+ var VIRTUAL = "virtual:uivisor-overlay";
16
+ var RESOLVED = "\0" + VIRTUAL;
17
+ function uivisor(options = {}) {
18
+ const include = options.include ?? /\.[jt]sx$/;
19
+ const attr = options.attr ?? "data-uiv-src";
20
+ let enabled = false;
21
+ return {
22
+ name: "uivisor",
23
+ enforce: "pre",
24
+ apply: options.force ? void 0 : "serve",
25
+ resolveId(id) {
26
+ if (id === VIRTUAL) return RESOLVED;
27
+ return null;
28
+ },
29
+ load(id) {
30
+ if (id === RESOLVED) return `import "uivisor/overlay";`;
31
+ return null;
32
+ },
33
+ configResolved(config) {
34
+ enabled = options.force === true || config.command === "serve";
35
+ },
36
+ transform(code, id) {
37
+ if (!enabled) return null;
38
+ const file = id.split("?")[0];
39
+ if (file.includes("/node_modules/")) return null;
40
+ if (!include.test(file)) return null;
41
+ if (!code.includes("<")) return null;
42
+ if (/@react-refresh|_jsxDEV|jsxDEV\(/.test(code.slice(0, 400))) {
43
+ warnOrder();
44
+ return null;
45
+ }
46
+ try {
47
+ const result = transformSync(code, {
48
+ filename: file,
49
+ cwd: process.cwd(),
50
+ babelrc: false,
51
+ configFile: false,
52
+ sourceMaps: true,
53
+ parserOpts: {
54
+ plugins: ["jsx", "typescript"],
55
+ sourceType: "module"
56
+ },
57
+ generatorOpts: { retainLines: true },
58
+ plugins: [[uivisorBabel, { attr }]]
59
+ });
60
+ if (!result?.code) return null;
61
+ return { code: result.code, map: result.map };
62
+ } catch {
63
+ return null;
64
+ }
65
+ },
66
+ transformIndexHtml() {
67
+ if (!enabled) return;
68
+ return [
69
+ {
70
+ tag: "script",
71
+ attrs: { type: "module", src: `/@id/${RESOLVED.replace("\0", "__x00__")}` },
72
+ injectTo: "body"
73
+ }
74
+ ];
75
+ }
76
+ };
77
+ }
78
+ export {
79
+ uivisor as default
80
+ };
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "uivisor",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "Dev-only visual UI tweaker that turns mouse edits into a precise, breakpoint-aware prompt for your AI coding agent — without touching your source.",
6
+ "license": "MIT",
7
+ "keywords": ["vite-plugin", "react", "devtools", "ai", "visual-editing", "tailwind"],
8
+ "exports": {
9
+ "./vite": {
10
+ "types": "./dist/vite/index.d.ts",
11
+ "import": "./dist/vite/index.js",
12
+ "default": "./dist/vite/index.js"
13
+ },
14
+ "./babel": {
15
+ "types": "./dist/babel/index.d.ts",
16
+ "import": "./dist/babel/index.js",
17
+ "default": "./dist/babel/index.js"
18
+ },
19
+ "./overlay": {
20
+ "types": "./dist/overlay/index.d.ts",
21
+ "import": "./dist/overlay/index.js",
22
+ "default": "./dist/overlay/index.js"
23
+ },
24
+ "./next": {
25
+ "types": "./dist/next/index.d.cts",
26
+ "import": "./dist/next/index.cjs",
27
+ "require": "./dist/next/index.cjs",
28
+ "default": "./dist/next/index.cjs"
29
+ },
30
+ "./next/loader": {
31
+ "require": "./dist/next/loader.cjs",
32
+ "default": "./dist/next/loader.cjs"
33
+ }
34
+ },
35
+ "files": ["dist"],
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "engines": {
40
+ "node": ">=18"
41
+ },
42
+ "workspaces": ["demo", "demo-next"],
43
+ "scripts": {
44
+ "build": "tsup",
45
+ "dev": "tsup --watch",
46
+ "test": "vitest run",
47
+ "typecheck": "tsc --noEmit",
48
+ "demo": "npm run build && npm --workspace demo run dev",
49
+ "prepublishOnly": "npm run build && vitest run"
50
+ },
51
+ "peerDependencies": {
52
+ "vite": ">=4"
53
+ },
54
+ "peerDependenciesMeta": {
55
+ "vite": { "optional": true }
56
+ },
57
+ "dependencies": {
58
+ "@babel/core": "^7.24.0"
59
+ },
60
+ "devDependencies": {
61
+ "@babel/types": "^7.24.0",
62
+ "@types/babel__core": "^7.20.5",
63
+ "@types/node": "^20.11.0",
64
+ "jsdom": "^24.0.0",
65
+ "tsup": "^8.0.0",
66
+ "typescript": "^5.4.0",
67
+ "vitest": "^1.6.0"
68
+ }
69
+ }