@base44-preview/vite-plugin 1.0.27-pr.98.8446f07 → 1.0.29-pr.91.4f81f8d
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/visual-edit-plugin.js +13 -21
- package/dist/visual-edit-plugin.js.map +1 -1
- package/package.json +1 -1
- package/src/visual-edit-plugin.md +10 -11
- package/src/visual-edit-plugin.ts +13 -24
|
@@ -73,28 +73,20 @@ export function visualEditPlugin() {
|
|
|
73
73
|
},
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
|
+
// Emit the canonical real path (src/pages/Home.jsx) the backend and sandbox use, NOT a
|
|
77
|
+
// legacy alias (pages/Home). The path is anchored on the last "src" segment with the
|
|
78
|
+
// extension retained, so consumers get the file's true sandbox path directly.
|
|
76
79
|
function extractFilename(id) {
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
// Drop any Vite query suffix (e.g. "?v=...") and normalize separators.
|
|
81
|
+
const cleanId = id.split("?")[0].replace(/\\/g, "/");
|
|
82
|
+
const parts = cleanId.split("/");
|
|
83
|
+
// Anchor on the LAST "src" segment so a "src" elsewhere in the absolute path
|
|
84
|
+
// (e.g. a user's home dir) can't mis-anchor. base44 apps keep all source under src/.
|
|
85
|
+
const srcIndex = parts.lastIndexOf("src");
|
|
86
|
+
if (srcIndex >= 0) {
|
|
87
|
+
return parts.slice(srcIndex).join("/"); // src/pages/Home.jsx, src/Layout.jsx, src/components/ui/Card.tsx
|
|
84
88
|
}
|
|
85
|
-
|
|
86
|
-
return
|
|
87
|
-
}
|
|
88
|
-
function findSegmentIndex(parts, segments) {
|
|
89
|
-
for (const segment of segments) {
|
|
90
|
-
const idx = parts.findIndex((part) => part === segment);
|
|
91
|
-
if (idx >= 0)
|
|
92
|
-
return idx;
|
|
93
|
-
}
|
|
94
|
-
return -1;
|
|
95
|
-
}
|
|
96
|
-
function stripExtension(filename) {
|
|
97
|
-
const dotIndex = filename.indexOf(".");
|
|
98
|
-
return dotIndex >= 0 ? filename.substring(0, dotIndex) : filename;
|
|
89
|
+
// Fallback: file not under src/ — use the bare filename (extension kept).
|
|
90
|
+
return parts[parts.length - 1] ?? "";
|
|
99
91
|
}
|
|
100
92
|
//# sourceMappingURL=visual-edit-plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visual-edit-plugin.js","sourceRoot":"","sources":["../src/visual-edit-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAElC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,UAAU,gBAAgB;IAC9B,OAAO;QACL,IAAI,EAAE,uBAAuB;QAC7B,KAAK,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,aAAa;QAChD,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,KAAK;QACZ,kBAAkB,CAAC,IAAS;YAC1B,MAAM,cAAc,GAAG,+GAA+G,CAAC;YACvI,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,cAAc,GAAG,SAAS,CAAC,CAAC;QAC7D,CAAC;QACD,SAAS,CAAC,IAAS,EAAE,EAAO;YAC1B,IAAI,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC;gBACpE,OAAO,IAAI,CAAC;YACd,CAAC;YAED,IAAI,CAAC,EAAE,CAAC,KAAK,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;iBACV,CAAC;YACJ,CAAC;QACH,CAAC;KACQ,CAAC;AACd,CAAC;AAED,uFAAuF;AACvF,qFAAqF;AACrF,8EAA8E;AAC9E,SAAS,eAAe,CAAC,EAAU;IACjC,uEAAuE;IACvE,MAAM,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACtD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjC,6EAA6E;IAC7E,qFAAqF;IACrF,MAAM,QAAQ,GAAG,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAC1C,IAAI,QAAQ,IAAI,CAAC,EAAE,CAAC;QAClB,OAAO,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,iEAAiE;IAC3G,CAAC;IACD,0EAA0E;IAC1E,OAAO,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AACvC,CAAC"}
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@ It adds two HTML `data-*` attributes to every JSX element:
|
|
|
14
14
|
|
|
15
15
|
// AFTER (served to browser):
|
|
16
16
|
<Button
|
|
17
|
-
data-source-location="components/Button:42:8"
|
|
17
|
+
data-source-location="src/components/Button.jsx:42:8"
|
|
18
18
|
data-dynamic-content="false"
|
|
19
19
|
className="px-4"
|
|
20
20
|
>Click me</Button>
|
|
@@ -65,19 +65,18 @@ It adds two HTML `data-*` attributes to every JSX element:
|
|
|
65
65
|
|
|
66
66
|
### Step 1: Filename Extraction (lines 123-173)
|
|
67
67
|
|
|
68
|
-
Builds
|
|
68
|
+
Builds the canonical real source path (the path the backend and sandbox use) from the full file path:
|
|
69
69
|
|
|
70
70
|
```
|
|
71
|
-
/Users/dev/project/src/pages/About/index.tsx → "pages/About/index"
|
|
72
|
-
/Users/dev/project/src/components/ui/Button.tsx → "components/ui/Button"
|
|
73
|
-
/Users/dev/project/src/Layout.tsx → "Layout"
|
|
71
|
+
/Users/dev/project/src/pages/About/index.tsx → "src/pages/About/index.tsx"
|
|
72
|
+
/Users/dev/project/src/components/ui/Button.tsx → "src/components/ui/Button.tsx"
|
|
73
|
+
/Users/dev/project/src/Layout.tsx → "src/Layout.tsx"
|
|
74
74
|
```
|
|
75
75
|
|
|
76
76
|
**Rules:**
|
|
77
|
-
-
|
|
78
|
-
-
|
|
79
|
-
-
|
|
80
|
-
- File extensions are always stripped
|
|
77
|
+
- Anchors on the last `src/` segment and keeps everything from there, preserving nested structure
|
|
78
|
+
- The file extension is retained (`.jsx`/`.tsx`/`.js`/`.ts`)
|
|
79
|
+
- Files not under `src/` → just the filename (extension kept)
|
|
81
80
|
|
|
82
81
|
### Step 2: AST Parsing (lines 177-196)
|
|
83
82
|
|
|
@@ -260,7 +259,7 @@ The parent window (editor UI) and the sandbox iframe can't share a DOM. The `dat
|
|
|
260
259
|
```
|
|
261
260
|
Parent Window (Editor UI) iframe Sandbox (React App)
|
|
262
261
|
───────────────────────── ──────────────────────────
|
|
263
|
-
"Select element components/Button:42:8" → querySelector('[data-source-location="components/Button:42:8"]')
|
|
262
|
+
"Select element src/components/Button.jsx:42:8" → querySelector('[data-source-location="src/components/Button.jsx:42:8"]')
|
|
264
263
|
← "Element found: classes='px-4', isDynamic=false"
|
|
265
264
|
"Update classes to 'px-6 py-3'" → element.setAttribute("class", "px-6 py-3")
|
|
266
265
|
```
|
|
@@ -305,7 +304,7 @@ The `transformIndexHtml` hook injects the Tailwind CSS CDN, enabling visual edit
|
|
|
305
304
|
│ │ React App (DOM) │ │
|
|
306
305
|
│ │ │ │
|
|
307
306
|
│ │ <div data-source-location= │ │
|
|
308
|
-
│ │ "pages/Home:10:4"
|
|
307
|
+
│ │ "src/pages/Home.jsx:10:4" │ │
|
|
309
308
|
│ │ data-dynamic-content="true"> │ │
|
|
310
309
|
│ │ {greeting} │ │
|
|
311
310
|
│ │ </div> │ │
|
|
@@ -81,30 +81,19 @@ export function visualEditPlugin() {
|
|
|
81
81
|
} as Plugin;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
// Emit the canonical real path (src/pages/Home.jsx) the backend and sandbox use, NOT a
|
|
85
|
+
// legacy alias (pages/Home). The path is anchored on the last "src" segment with the
|
|
86
|
+
// extension retained, so consumers get the file's true sandbox path directly.
|
|
84
87
|
function extractFilename(id: string): string {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
return
|
|
88
|
+
// Drop any Vite query suffix (e.g. "?v=...") and normalize separators.
|
|
89
|
+
const cleanId = id.split("?")[0]!.replace(/\\/g, "/");
|
|
90
|
+
const parts = cleanId.split("/");
|
|
91
|
+
// Anchor on the LAST "src" segment so a "src" elsewhere in the absolute path
|
|
92
|
+
// (e.g. a user's home dir) can't mis-anchor. base44 apps keep all source under src/.
|
|
93
|
+
const srcIndex = parts.lastIndexOf("src");
|
|
94
|
+
if (srcIndex >= 0) {
|
|
95
|
+
return parts.slice(srcIndex).join("/"); // src/pages/Home.jsx, src/Layout.jsx, src/components/ui/Card.tsx
|
|
93
96
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return stripExtension(lastPart);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function findSegmentIndex(parts: string[], segments: string[]): number {
|
|
100
|
-
for (const segment of segments) {
|
|
101
|
-
const idx = parts.findIndex((part) => part === segment);
|
|
102
|
-
if (idx >= 0) return idx;
|
|
103
|
-
}
|
|
104
|
-
return -1;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function stripExtension(filename: string): string {
|
|
108
|
-
const dotIndex = filename.indexOf(".");
|
|
109
|
-
return dotIndex >= 0 ? filename.substring(0, dotIndex) : filename;
|
|
97
|
+
// Fallback: file not under src/ — use the bare filename (extension kept).
|
|
98
|
+
return parts[parts.length - 1] ?? "";
|
|
110
99
|
}
|