@bitovi/vybit 0.11.1 → 0.11.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.
- package/overlay/dist/overlay.js +61 -16
- package/package.json +1 -1
- package/server/app.ts +5 -0
- package/server/tailwind-v3.ts +9 -1
- package/server/tailwind-v4.ts +5 -1
package/overlay/dist/overlay.js
CHANGED
|
@@ -2132,21 +2132,37 @@ ${pad}</${tag}>`;
|
|
|
2132
2132
|
}
|
|
2133
2133
|
if (newClass) {
|
|
2134
2134
|
try {
|
|
2135
|
+
console.log("[vybit-patcher] Fetching CSS for class:", newClass, "from", `${serverOrigin}/css`);
|
|
2135
2136
|
const res = await fetch(`${serverOrigin}/css`, {
|
|
2136
2137
|
method: "POST",
|
|
2137
2138
|
headers: { "Content-Type": "application/json" },
|
|
2138
2139
|
body: JSON.stringify({ classes: [newClass] })
|
|
2139
2140
|
});
|
|
2140
2141
|
if (gen !== previewGeneration) return;
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2142
|
+
if (!res.ok) {
|
|
2143
|
+
const errBody = await res.text();
|
|
2144
|
+
console.error("[vybit-patcher] CSS fetch FAILED:", res.status, errBody);
|
|
2145
|
+
} else {
|
|
2146
|
+
const { css } = await res.json();
|
|
2147
|
+
console.log("[vybit-patcher] CSS received for", newClass, ":", css ? `${css.length} chars` : "(empty)");
|
|
2148
|
+
console.log("[vybit-patcher] CSS content:", css || "(none)");
|
|
2149
|
+
if (gen !== previewGeneration) return;
|
|
2150
|
+
if (!previewStyleEl) {
|
|
2151
|
+
previewStyleEl = document.createElement("style");
|
|
2152
|
+
previewStyleEl.setAttribute("data-tw-preview", "");
|
|
2153
|
+
document.head.appendChild(previewStyleEl);
|
|
2154
|
+
console.log("[vybit-patcher] Created <style data-tw-preview> in document.head");
|
|
2155
|
+
}
|
|
2156
|
+
previewStyleEl.textContent = css;
|
|
2157
|
+
console.log(
|
|
2158
|
+
"[vybit-patcher] Style element in DOM:",
|
|
2159
|
+
document.head.contains(previewStyleEl),
|
|
2160
|
+
"textContent length:",
|
|
2161
|
+
previewStyleEl.textContent?.length
|
|
2162
|
+
);
|
|
2147
2163
|
}
|
|
2148
|
-
|
|
2149
|
-
|
|
2164
|
+
} catch (err) {
|
|
2165
|
+
console.error("[vybit-patcher] CSS fetch error:", err);
|
|
2150
2166
|
}
|
|
2151
2167
|
}
|
|
2152
2168
|
if (gen !== previewGeneration) return;
|
|
@@ -2159,6 +2175,13 @@ ${pad}</${tag}>`;
|
|
|
2159
2175
|
if (oldClass) node.classList.remove(oldClass);
|
|
2160
2176
|
if (newClass) node.classList.add(newClass);
|
|
2161
2177
|
}
|
|
2178
|
+
console.log("[vybit-patcher] Applied class swap:", oldClass, "\u2192", newClass, "on", elements.length, "elements");
|
|
2179
|
+
if (elements[0]) {
|
|
2180
|
+
console.log("[vybit-patcher] Element className after swap:", elements[0].className);
|
|
2181
|
+
const computed = window.getComputedStyle(elements[0]);
|
|
2182
|
+
if (newClass.startsWith("bg-")) console.log("[vybit-patcher] Computed background:", computed.backgroundColor);
|
|
2183
|
+
if (newClass.startsWith("p-") || newClass.startsWith("px-") || newClass.startsWith("py-")) console.log("[vybit-patcher] Computed padding:", computed.padding);
|
|
2184
|
+
}
|
|
2162
2185
|
}
|
|
2163
2186
|
async function applyPreviewBatch(elements, pairs, serverOrigin) {
|
|
2164
2187
|
const gen = ++previewGeneration;
|
|
@@ -2171,21 +2194,37 @@ ${pad}</${tag}>`;
|
|
|
2171
2194
|
const newClasses = pairs.map((p) => p.newClass).filter(Boolean);
|
|
2172
2195
|
if (newClasses.length > 0) {
|
|
2173
2196
|
try {
|
|
2197
|
+
console.log("[vybit-patcher] Fetching CSS for batch:", newClasses, "from", `${serverOrigin}/css`);
|
|
2174
2198
|
const res = await fetch(`${serverOrigin}/css`, {
|
|
2175
2199
|
method: "POST",
|
|
2176
2200
|
headers: { "Content-Type": "application/json" },
|
|
2177
2201
|
body: JSON.stringify({ classes: newClasses })
|
|
2178
2202
|
});
|
|
2179
2203
|
if (gen !== previewGeneration) return;
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2204
|
+
if (!res.ok) {
|
|
2205
|
+
const errBody = await res.text();
|
|
2206
|
+
console.error("[vybit-patcher] CSS batch fetch FAILED:", res.status, errBody);
|
|
2207
|
+
} else {
|
|
2208
|
+
const { css } = await res.json();
|
|
2209
|
+
console.log("[vybit-patcher] CSS batch received:", css ? `${css.length} chars` : "(empty)");
|
|
2210
|
+
console.log("[vybit-patcher] CSS batch content:", css || "(none)");
|
|
2211
|
+
if (gen !== previewGeneration) return;
|
|
2212
|
+
if (!previewStyleEl) {
|
|
2213
|
+
previewStyleEl = document.createElement("style");
|
|
2214
|
+
previewStyleEl.setAttribute("data-tw-preview", "");
|
|
2215
|
+
document.head.appendChild(previewStyleEl);
|
|
2216
|
+
console.log("[vybit-patcher] Created <style data-tw-preview> in document.head");
|
|
2217
|
+
}
|
|
2218
|
+
previewStyleEl.textContent = css;
|
|
2219
|
+
console.log(
|
|
2220
|
+
"[vybit-patcher] Style element in DOM:",
|
|
2221
|
+
document.head.contains(previewStyleEl),
|
|
2222
|
+
"textContent length:",
|
|
2223
|
+
previewStyleEl.textContent?.length
|
|
2224
|
+
);
|
|
2186
2225
|
}
|
|
2187
|
-
|
|
2188
|
-
|
|
2226
|
+
} catch (err) {
|
|
2227
|
+
console.error("[vybit-patcher] CSS batch fetch error:", err);
|
|
2189
2228
|
}
|
|
2190
2229
|
}
|
|
2191
2230
|
if (gen !== previewGeneration) return;
|
|
@@ -4338,14 +4377,20 @@ ${pad}</${tag}>`;
|
|
|
4338
4377
|
setSelectMode(false);
|
|
4339
4378
|
}
|
|
4340
4379
|
} else if (msg.type === "PATCH_PREVIEW" && currentEquivalentNodes.length > 0) {
|
|
4380
|
+
console.log("[vybit-overlay] PATCH_PREVIEW:", msg.oldClass, "\u2192", msg.newClass, "nodes:", currentEquivalentNodes.length);
|
|
4341
4381
|
applyPreview(
|
|
4342
4382
|
currentEquivalentNodes,
|
|
4343
4383
|
msg.oldClass,
|
|
4344
4384
|
msg.newClass,
|
|
4345
4385
|
SERVER_ORIGIN
|
|
4346
4386
|
);
|
|
4387
|
+
} else if (msg.type === "PATCH_PREVIEW" && currentEquivalentNodes.length === 0) {
|
|
4388
|
+
console.warn("[vybit-overlay] PATCH_PREVIEW DROPPED \u2014 no selected elements! oldClass:", msg.oldClass, "newClass:", msg.newClass);
|
|
4347
4389
|
} else if (msg.type === "PATCH_PREVIEW_BATCH" && currentEquivalentNodes.length > 0) {
|
|
4390
|
+
console.log("[vybit-overlay] PATCH_PREVIEW_BATCH:", msg.pairs, "nodes:", currentEquivalentNodes.length);
|
|
4348
4391
|
applyPreviewBatch(currentEquivalentNodes, msg.pairs, SERVER_ORIGIN);
|
|
4392
|
+
} else if (msg.type === "PATCH_PREVIEW_BATCH" && currentEquivalentNodes.length === 0) {
|
|
4393
|
+
console.warn("[vybit-overlay] PATCH_PREVIEW_BATCH DROPPED \u2014 no selected elements!", msg.pairs);
|
|
4349
4394
|
} else if (msg.type === "PATCH_REVERT") {
|
|
4350
4395
|
revertPreview();
|
|
4351
4396
|
} else if (msg.type === "PATCH_REVERT_STAGED" && currentEquivalentNodes.length > 0) {
|
package/package.json
CHANGED
package/server/app.ts
CHANGED
|
@@ -53,12 +53,17 @@ export function createApp(packageRoot: string, storybookUrl: string | null = nul
|
|
|
53
53
|
|
|
54
54
|
app.post("/css", express.json(), async (req, res) => {
|
|
55
55
|
const { classes } = req.body as { classes?: unknown };
|
|
56
|
+
console.error("[http] POST /css — requested classes:", classes);
|
|
56
57
|
if (!Array.isArray(classes) || classes.some((c) => typeof c !== "string")) {
|
|
58
|
+
console.error("[http] POST /css — invalid request body");
|
|
57
59
|
res.status(400).json({ error: "classes must be an array of strings" });
|
|
58
60
|
return;
|
|
59
61
|
}
|
|
60
62
|
try {
|
|
61
63
|
const css = await generateCssForClasses(classes as string[]);
|
|
64
|
+
console.error(`[http] POST /css — generated ${css.length} chars for [${classes.join(', ')}]`);
|
|
65
|
+
if (css.length < 500) console.error("[http] POST /css — full CSS:", css);
|
|
66
|
+
else console.error("[http] POST /css — CSS preview:", css.substring(0, 300), "...");
|
|
62
67
|
res.json({ css });
|
|
63
68
|
} catch (err) {
|
|
64
69
|
const message = err instanceof Error ? err.message : String(err);
|
package/server/tailwind-v3.ts
CHANGED
|
@@ -462,10 +462,15 @@ export class TailwindV3Adapter implements TailwindAdapter {
|
|
|
462
462
|
let userConfig: object = {};
|
|
463
463
|
if (configPath) {
|
|
464
464
|
try {
|
|
465
|
+
console.error(`[tailwind-v3] Loading config from: ${configPath}`);
|
|
465
466
|
userConfig = (await import(pathToFileURL(configPath).href)).default;
|
|
466
|
-
|
|
467
|
+
console.error(`[tailwind-v3] Config loaded successfully, keys:`, Object.keys(userConfig));
|
|
468
|
+
} catch (err) {
|
|
469
|
+
console.error(`[tailwind-v3] Failed to load config from ${configPath}:`, err);
|
|
467
470
|
// fall through to empty config
|
|
468
471
|
}
|
|
472
|
+
} else {
|
|
473
|
+
console.error(`[tailwind-v3] No config file found in ${cwd}`);
|
|
469
474
|
}
|
|
470
475
|
|
|
471
476
|
// Load postcss and tailwindcss as a PostCSS plugin from the target project
|
|
@@ -475,6 +480,7 @@ export class TailwindV3Adapter implements TailwindAdapter {
|
|
|
475
480
|
await import(pathToFileURL(req.resolve("tailwindcss")).href)
|
|
476
481
|
).default;
|
|
477
482
|
|
|
483
|
+
console.error(`[tailwind-v3] Running PostCSS with safelist:`, classes);
|
|
478
484
|
const result = await postcss([
|
|
479
485
|
tailwindPlugin({
|
|
480
486
|
...userConfig,
|
|
@@ -483,6 +489,8 @@ export class TailwindV3Adapter implements TailwindAdapter {
|
|
|
483
489
|
}),
|
|
484
490
|
]).process("@tailwind utilities;", { from: undefined });
|
|
485
491
|
|
|
492
|
+
console.error(`[tailwind-v3] PostCSS result: ${result.css.length} chars`);
|
|
493
|
+
if (result.css.length < 500) console.error(`[tailwind-v3] Full CSS:`, result.css);
|
|
486
494
|
return result.css;
|
|
487
495
|
}
|
|
488
496
|
}
|
package/server/tailwind-v4.ts
CHANGED
|
@@ -267,7 +267,11 @@ export class TailwindV4Adapter implements TailwindAdapter {
|
|
|
267
267
|
}
|
|
268
268
|
|
|
269
269
|
async generateCssForClasses(classes: string[]): Promise<string> {
|
|
270
|
+
console.error(`[tailwind-v4] Generating CSS for classes:`, classes);
|
|
270
271
|
const compiler = await getCompiler();
|
|
271
|
-
|
|
272
|
+
const css = compiler.build(classes);
|
|
273
|
+
console.error(`[tailwind-v4] Generated ${css.length} chars`);
|
|
274
|
+
if (css.length < 500) console.error(`[tailwind-v4] Full CSS:`, css);
|
|
275
|
+
return css;
|
|
272
276
|
}
|
|
273
277
|
}
|