Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .changeset/remove-style-feature.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/semantic-selector-context.md

This file was deleted.

6 changes: 6 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @react-grab/cli

## 0.2.0

### Minor Changes

- f350003: Remove the Style action and panel, including its keyboard shortcuts, inline previews, CSS property controls, design-token handling, and edit-related action context and renderer types. Simplify the toolbar to its Copy control while keeping Comment available through the context menu and action menu.

## 0.1.50

## 0.1.49
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-grab/cli",
"version": "0.1.50",
"version": "0.2.0",
"repository": {
"type": "git",
"url": "git+https://github.com/aidenybai/react-grab.git"
Expand Down
11 changes: 11 additions & 0 deletions packages/grab/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# grab

## 0.2.0

### Minor Changes

- f350003: Remove the Style action and panel, including its keyboard shortcuts, inline previews, CSS property controls, design-token handling, and edit-related action context and renderer types. Simplify the toolbar to its Copy control while keeping Comment available through the context menu and action menu.

### Patch Changes

- Updated dependencies [f350003]
- @react-grab/cli@0.2.0

## 0.1.50

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/grab/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "grab",
"version": "0.1.50",
"version": "0.2.0",
"description": "Select context for coding agents directly from your website",
"keywords": [
"agent",
Expand Down
12 changes: 12 additions & 0 deletions packages/react-grab/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# react-grab

## 0.2.0

### Minor Changes

- f350003: Remove the Style action and panel, including its keyboard shortcuts, inline previews, CSS property controls, design-token handling, and edit-related action context and renderer types. Simplify the toolbar to its Copy control while keeping Comment available through the context menu and action menu.

### Patch Changes

- 4dbdee5: Improve copied element context and labels with stable semantic selectors, authored component names, nearest-source resolution, race-safe refresh-aware source caching, bounded previews and keys, nested control labels, consistent trace budgets, and lossless multi-element selection.
- Updated dependencies [f350003]
- @react-grab/cli@0.2.0

## 0.1.50

### Patch Changes
Expand Down
46 changes: 46 additions & 0 deletions packages/react-grab/e2e/csp.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { expect, test } from "./fixtures.js";

const STRICT_STYLE_POLICY = "style-src 'self' 'unsafe-inline'";
const GOOGLE_FONTS_STYLESHEET_HOST = "fonts.googleapis.com";

test("does not load an external font stylesheet under a strict style CSP", async ({
reactGrab,
}) => {
const cspViolations: string[] = [];

reactGrab.page.on("console", (message) => {
if (
message.type() === "error" &&
message.text().includes("Content Security Policy") &&
message.text().includes(GOOGLE_FONTS_STYLESHEET_HOST)
) {
cspViolations.push(message.text());
}
});

await reactGrab.page.route("**/*", async (route) => {
if (route.request().resourceType() !== "document") {
await route.continue();
return;
}

const response = await route.fetch();
await route.fulfill({
response,
headers: {
...response.headers(),
"content-security-policy": STRICT_STYLE_POLICY,
},
});
});

await reactGrab.page.reload({ waitUntil: "domcontentloaded" });
await expect.poll(() => reactGrab.getOverlayHost().count()).toBe(1);

const overlayStyles = await reactGrab.getOverlayHost().evaluate((host) => {
return host.shadowRoot?.querySelector("style")?.textContent ?? "";
});

expect(overlayStyles).not.toContain(GOOGLE_FONTS_STYLESHEET_HOST);
expect(cspViolations).toEqual([]);
});
2 changes: 1 addition & 1 deletion packages/react-grab/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-grab",
"version": "0.1.50",
"version": "0.2.0",
"description": "Select context for coding agents directly from your website",
"keywords": [
"agent",
Expand Down
5 changes: 1 addition & 4 deletions packages/react-grab/src/utils/mount-root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ import { detectCspNonce } from "./detect-csp-nonce.js";
import { hideFromThirdParties } from "./hide-from-third-parties.js";
import { REACT_GRAB_ATTRIBUTE_NAME } from "./react-grab-attribute-name.js";

const FONT_IMPORT =
'@import url("https://fonts.googleapis.com/css2?family=Geist:wght@500&display=swap");';

// Mounting into <body> (not <html>) keeps React hydration happy: appending a
// <div> directly to <html> throws "In HTML, <div> cannot be a child of <html>"
// during hydration (see vercel/next.js#51242), which surfaces in Next.js's dev
Expand Down Expand Up @@ -93,7 +90,7 @@ export const mountRoot = (cssText?: string): MountRootResult => {
const styleElement = document.createElement("style");
const nonce = detectCspNonce();
if (nonce) styleElement.nonce = nonce;
styleElement.textContent = `${FONT_IMPORT}\n${cssText ?? ""}`;
styleElement.textContent = cssText ?? "";
shadowRoot.appendChild(styleElement);

const root = document.createElement("div");
Expand Down
Loading