@react-ui-org/react-ui 0.64.1 → 0.65.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.
- package/README.md +3 -6
- package/dist/react-ui.css +16 -16
- package/dist/react-ui.d.ts +1928 -0
- package/dist/react-ui.development.css +2916 -2915
- package/dist/react-ui.development.js +2019 -1051
- package/dist/react-ui.js +1 -1
- package/package.json +74 -70
- package/src/components/Alert/{Alert.jsx → Alert.tsx} +8 -43
- package/src/components/Alert/Alert.types.ts +34 -0
- package/src/components/Alert/README.md +1 -1
- package/src/components/Alert/index.ts +2 -0
- package/src/components/Badge/Badge.tsx +30 -0
- package/src/components/Badge/Badge.types.ts +24 -0
- package/src/components/Badge/README.md +1 -1
- package/src/components/Badge/index.ts +5 -0
- package/src/components/Button/Button.tsx +110 -0
- package/src/components/Button/Button.types.ts +93 -0
- package/src/components/Button/README.md +1 -1
- package/src/components/Button/helpers/{getRootLabelVisibilityClassName.js → getRootLabelVisibilityClassName.ts} +4 -1
- package/src/components/Button/index.ts +6 -0
- package/src/components/ButtonGroup/{ButtonGroup.jsx → ButtonGroup.tsx} +9 -40
- package/src/components/ButtonGroup/ButtonGroup.types.ts +45 -0
- package/src/components/ButtonGroup/ButtonGroupContext.ts +4 -0
- package/src/components/ButtonGroup/README.md +1 -1
- package/src/components/ButtonGroup/{index.js → index.ts} +4 -0
- package/src/components/Card/Card.tsx +33 -0
- package/src/components/Card/Card.types.ts +46 -0
- package/src/components/Card/{CardBody.jsx → CardBody.tsx} +4 -11
- package/src/components/Card/{CardFooter.jsx → CardFooter.tsx} +4 -15
- package/src/components/Card/README.md +6 -7
- package/src/components/Card/{index.js → index.ts} +5 -0
- package/src/components/CheckboxField/CheckboxField.tsx +81 -0
- package/src/components/CheckboxField/CheckboxField.types.ts +63 -0
- package/src/components/CheckboxField/README.md +67 -42
- package/src/components/CheckboxField/index.ts +5 -0
- package/src/components/FileInputField/{FileInputField.jsx → FileInputField.tsx} +42 -128
- package/src/components/FileInputField/FileInputField.types.ts +100 -0
- package/src/components/FileInputField/README.md +1 -1
- package/src/components/FileInputField/index.ts +6 -0
- package/src/components/FormLayout/FormLayout.module.scss +1 -1
- package/src/components/FormLayout/{FormLayout.jsx → FormLayout.tsx} +15 -50
- package/src/components/FormLayout/FormLayout.types.ts +55 -0
- package/src/components/FormLayout/FormLayoutContext.ts +4 -0
- package/src/components/FormLayout/{FormLayoutCustomField.jsx → FormLayoutCustomField.tsx} +10 -65
- package/src/components/FormLayout/FormLayoutCustomField.types.ts +59 -0
- package/src/components/FormLayout/FormLayoutCustomFieldContext.ts +4 -0
- package/src/components/FormLayout/README.md +4 -6
- package/src/components/FormLayout/index.ts +14 -0
- package/src/components/Grid/Grid.module.scss +1 -1
- package/src/components/Grid/Grid.tsx +50 -0
- package/src/components/Grid/Grid.types.ts +108 -0
- package/src/components/Grid/GridSpan.tsx +36 -0
- package/src/components/Grid/README.md +2 -2
- package/src/components/Grid/_helpers/generateResponsiveCustomProperties.ts +32 -0
- package/src/components/Grid/index.ts +9 -0
- package/src/components/InputGroup/{InputGroup.jsx → InputGroup.tsx} +25 -89
- package/src/components/InputGroup/InputGroup.types.ts +80 -0
- package/src/components/InputGroup/InputGroupContext.ts +4 -0
- package/src/components/InputGroup/README.md +5 -1
- package/src/components/InputGroup/{index.js → index.ts} +4 -0
- package/src/components/Modal/Modal.tsx +172 -0
- package/src/components/Modal/Modal.types.ts +181 -0
- package/src/components/Modal/ModalBody.tsx +34 -0
- package/src/components/Modal/{ModalCloseButton.jsx → ModalCloseButton.tsx} +6 -19
- package/src/components/Modal/{ModalContent.jsx → ModalContent.tsx} +4 -15
- package/src/components/Modal/ModalFooter.tsx +27 -0
- package/src/components/Modal/ModalHeader.tsx +27 -0
- package/src/components/Modal/ModalTitle.tsx +29 -0
- package/src/components/Modal/README.md +9 -9
- package/src/components/Modal/_helpers/{dialogOnCancelHandler.js → dialogOnCancelHandler.ts} +11 -1
- package/src/components/Modal/_helpers/{dialogOnClickHandler.js → dialogOnClickHandler.ts} +13 -7
- package/src/components/Modal/_helpers/{dialogOnCloseHandler.js → dialogOnCloseHandler.ts} +11 -1
- package/src/components/Modal/_helpers/{dialogOnKeyDownHandler.js → dialogOnKeyDownHandler.ts} +19 -6
- package/src/components/Modal/_helpers/{getJustifyClassName.js → getJustifyClassName.ts} +4 -1
- package/src/components/Modal/_helpers/getPositionClassName.ts +10 -0
- package/src/components/Modal/_helpers/getScrollingClassName.ts +14 -0
- package/src/components/Modal/_helpers/{getSizeClassName.js → getSizeClassName.ts} +4 -1
- package/src/components/Modal/_hooks/{useModalFocus.js → useModalFocus.ts} +9 -5
- package/src/components/Modal/_hooks/{useModalScrollPrevention.js → useModalScrollPrevention.ts} +4 -1
- package/src/components/Modal/{index.js → index.ts} +14 -0
- package/src/components/Paper/{Paper.jsx → Paper.tsx} +6 -26
- package/src/components/Paper/Paper.types.ts +19 -0
- package/src/components/Paper/README.md +3 -4
- package/src/components/Paper/index.ts +2 -0
- package/src/components/Popover/Popover.module.scss +1 -1
- package/src/components/Popover/Popover.tsx +61 -0
- package/src/components/Popover/Popover.types.ts +75 -0
- package/src/components/Popover/PopoverWrapper.tsx +27 -0
- package/src/components/Popover/README.md +34 -22
- package/src/components/Popover/_helpers/{cleanPlacementStyle.js → cleanPlacementStyle.ts} +4 -1
- package/src/components/Popover/_helpers/{getRootAlignmentClassName.js → getRootAlignmentClassName.ts} +4 -1
- package/src/components/Popover/_helpers/{getRootSideClassName.js → getRootSideClassName.ts} +4 -1
- package/src/components/Popover/index.ts +8 -0
- package/src/components/Radio/README.md +85 -45
- package/src/components/Radio/{Radio.jsx → Radio.tsx} +11 -107
- package/src/components/Radio/Radio.types.ts +90 -0
- package/src/components/Radio/index.ts +5 -0
- package/src/components/ScrollView/README.md +1 -1
- package/src/components/ScrollView/ScrollView.module.scss +5 -0
- package/src/components/ScrollView/{ScrollView.jsx → ScrollView.tsx} +55 -166
- package/src/components/ScrollView/ScrollView.types.ts +121 -0
- package/src/components/ScrollView/_helpers/getElementsPositionDifference.ts +17 -0
- package/src/components/ScrollView/_hooks/{useLoadResizeHook.js → useLoadResizeHook.ts} +14 -3
- package/src/components/ScrollView/_hooks/{useScrollPositionHook.js → useScrollPositionHook.ts} +11 -4
- package/src/components/ScrollView/index.ts +6 -0
- package/src/components/SelectField/README.md +84 -45
- package/src/components/SelectField/SelectField.tsx +139 -0
- package/src/components/SelectField/SelectField.types.ts +120 -0
- package/src/components/SelectField/_components/Option/Option.tsx +19 -0
- package/src/components/SelectField/_components/Option/Option.types.ts +21 -0
- package/src/components/SelectField/_components/Option/index.ts +2 -0
- package/src/components/SelectField/index.ts +7 -0
- package/src/components/Table/README.md +1 -1
- package/src/components/Table/{Table.jsx → Table.tsx} +4 -43
- package/src/components/Table/Table.types.ts +51 -0
- package/src/components/Table/_components/TableBodyCell/TableBodyCell.tsx +20 -0
- package/src/components/Table/_components/TableBodyCell/TableBodyCell.types.ts +20 -0
- package/src/components/Table/_components/TableBodyCell/index.ts +2 -0
- package/src/components/Table/_components/TableHeaderCell/{TableHeaderCell.jsx → TableHeaderCell.tsx} +3 -34
- package/src/components/Table/_components/TableHeaderCell/TableHeaderCell.types.ts +20 -0
- package/src/components/Table/_components/TableHeaderCell/index.ts +2 -0
- package/src/components/Table/index.ts +8 -0
- package/src/components/Tabs/README.md +2 -2
- package/src/components/Tabs/{Tabs.jsx → Tabs.tsx} +4 -20
- package/src/components/Tabs/Tabs.types.ts +19 -0
- package/src/components/Tabs/TabsItem.tsx +49 -0
- package/src/components/Tabs/TabsItem.types.ts +42 -0
- package/src/components/Tabs/index.ts +4 -0
- package/src/components/Text/README.md +1 -1
- package/src/components/Text/Text.module.scss +5 -7
- package/src/components/Text/Text.tsx +46 -0
- package/src/components/Text/Text.types.ts +31 -0
- package/src/components/Text/_helpers/getRootClampClassName.ts +13 -0
- package/src/components/Text/_helpers/getRootHyphensClassName.ts +14 -0
- package/src/components/Text/_helpers/getRootWordWrappingClassName.ts +14 -0
- package/src/components/Text/index.ts +6 -0
- package/src/components/TextArea/README.md +5 -8
- package/src/components/TextArea/TextArea.tsx +95 -0
- package/src/components/TextArea/TextArea.types.ts +75 -0
- package/src/components/TextArea/index.ts +5 -0
- package/src/components/TextField/README.md +5 -7
- package/src/components/TextField/TextField.tsx +112 -0
- package/src/components/TextField/TextField.types.ts +94 -0
- package/src/components/TextField/index.ts +6 -0
- package/src/components/TextLink/README.md +1 -1
- package/src/components/TextLink/{TextLink.jsx → TextLink.tsx} +4 -15
- package/src/components/TextLink/TextLink.types.ts +12 -0
- package/src/components/TextLink/index.ts +2 -0
- package/src/components/Toggle/README.md +67 -42
- package/src/components/Toggle/Toggle.tsx +82 -0
- package/src/components/Toggle/Toggle.types.ts +58 -0
- package/src/components/Toggle/index.ts +5 -0
- package/src/components/Toolbar/README.md +3 -3
- package/src/components/Toolbar/Toolbar.tsx +41 -0
- package/src/components/Toolbar/Toolbar.types.ts +74 -0
- package/src/components/Toolbar/ToolbarGroup.tsx +38 -0
- package/src/components/Toolbar/{ToolbarItem.jsx → ToolbarItem.tsx} +5 -21
- package/src/components/Toolbar/_helpers/{getAlignClassName.js → getAlignClassName.ts} +8 -1
- package/src/components/Toolbar/_helpers/{getJustifyClassName.js → getJustifyClassName.ts} +4 -1
- package/src/components/Toolbar/{index.js → index.ts} +7 -0
- package/src/components/_helpers/{getRootColorClassName.js → getRootColorClassName.ts} +6 -1
- package/src/components/_helpers/{getRootPriorityClassName.js → getRootPriorityClassName.ts} +6 -1
- package/src/components/_helpers/{getRootSizeClassName.js → getRootSizeClassName.ts} +6 -1
- package/src/components/_helpers/{getRootValidationStateClassName.js → getRootValidationStateClassName.ts} +6 -1
- package/src/components/_helpers/resolveContextOrProp.ts +13 -0
- package/src/helpers/classNames/{classNames.js → classNames.ts} +2 -2
- package/src/helpers/isChildrenEmpty/isChildrenEmpty.ts +5 -0
- package/src/helpers/transferProps/transferProps.ts +50 -0
- package/src/helpers/transferProps/transferProps.types.ts +11 -0
- package/src/index.ts +211 -0
- package/src/providers/globalProps/GlobalProps.types.ts +30 -0
- package/src/providers/globalProps/GlobalPropsContext.ts +6 -0
- package/src/providers/globalProps/{GlobalPropsProvider.jsx → GlobalPropsProvider.tsx} +8 -15
- package/src/providers/globalProps/{index.js → index.ts} +4 -0
- package/src/providers/globalProps/withGlobalProps.tsx +36 -0
- package/src/providers/translations/Translations.types.ts +26 -0
- package/src/providers/translations/TranslationsContext.ts +7 -0
- package/src/providers/translations/{TranslationsProvider.jsx → TranslationsProvider.tsx} +8 -15
- package/src/providers/translations/{index.js → index.ts} +5 -0
- package/src/styles/tools/_accessibility.scss +2 -2
- package/src/translations/{en.js → en.ts} +3 -1
- package/src/types/breakpoints.ts +1 -0
- package/src/types/colors.ts +7 -0
- package/src/types/index.ts +13 -0
- package/src/types/labelPositions.ts +1 -0
- package/src/types/layouts.ts +1 -0
- package/src/types/modules.d.ts +16 -0
- package/src/types/priorities.ts +1 -0
- package/src/types/sizes.ts +1 -0
- package/src/types/styles.ts +4 -0
- package/src/types/validationStates.ts +1 -0
- package/src/utils/mergeDeep.ts +34 -0
- package/src/utils/mergeDeep.types.ts +4 -0
- package/.claude/agents/code-reviewer.md +0 -122
- package/.claude/rules/code.md +0 -22
- package/.claude/rules/docs.md +0 -35
- package/.claude/rules/frontend.md +0 -72
- package/.claude/rules/git.md +0 -13
- package/.claude/rules/safety-guards.md +0 -9
- package/.claude/rules/styling.md +0 -32
- package/.claude/rules/testing.md +0 -59
- package/.claude/settings.json +0 -32
- package/.claude/skills/commit/SKILL.md +0 -54
- package/.devcontainer/devcontainer.json +0 -23
- package/.eslintrc-ts +0 -40
- package/.mcp.json +0 -8
- package/.nvmrc +0 -1
- package/CLAUDE.md +0 -82
- package/docker-compose.base.yml +0 -93
- package/docker-compose.yml.dist +0 -41
- package/jest.config-ts.js +0 -34
- package/opencode.json +0 -10
- package/playwright-ct.config.ts +0 -68
- package/scripts/auto-start-mkdocs.sh +0 -5
- package/scripts/auto-start-node.sh +0 -33
- package/scripts/mcps/chrome-host/README.md +0 -118
- package/scripts/mcps/chrome-host/cdp_proxy.py +0 -90
- package/scripts/mcps/chrome-host/mcp-entry.sh +0 -33
- package/scripts/mcps/chrome-host/mcp-launch.sh +0 -36
- package/scripts/mcps/chrome-host/mcp-setup.sh +0 -70
- package/scripts/mcps/chrome-host/start-host-chrome.sh +0 -267
- package/setup.sh +0 -107
- package/src/CNAME +0 -1
- package/src/components/Alert/index.js +0 -1
- package/src/components/Badge/Badge.jsx +0 -51
- package/src/components/Badge/index.js +0 -1
- package/src/components/Button/Button.jsx +0 -203
- package/src/components/Button/helpers/getRootPriorityClassName.js +0 -15
- package/src/components/Button/index.js +0 -1
- package/src/components/ButtonGroup/ButtonGroupContext.js +0 -3
- package/src/components/Card/Card.jsx +0 -67
- package/src/components/CheckboxField/CheckboxField.jsx +0 -144
- package/src/components/CheckboxField/index.js +0 -1
- package/src/components/FileInputField/index.js +0 -1
- package/src/components/FormLayout/FormLayoutContext.js +0 -3
- package/src/components/FormLayout/FormLayoutCustomFieldContext.js +0 -3
- package/src/components/FormLayout/index.js +0 -4
- package/src/components/Grid/Grid.jsx +0 -225
- package/src/components/Grid/GridSpan.jsx +0 -88
- package/src/components/Grid/_helpers/generateResponsiveCustomProperties.js +0 -22
- package/src/components/Grid/index.js +0 -2
- package/src/components/InputGroup/InputGroupContext.js +0 -3
- package/src/components/Modal/Modal.jsx +0 -262
- package/src/components/Modal/ModalBody.jsx +0 -60
- package/src/components/Modal/ModalFooter.jsx +0 -42
- package/src/components/Modal/ModalHeader.jsx +0 -42
- package/src/components/Modal/ModalTitle.jsx +0 -42
- package/src/components/Modal/_helpers/getPositionClassName.js +0 -7
- package/src/components/Modal/_helpers/getScrollingClassName.js +0 -11
- package/src/components/Paper/index.js +0 -1
- package/src/components/Popover/Popover.jsx +0 -124
- package/src/components/Popover/PopoverWrapper.jsx +0 -38
- package/src/components/Popover/index.js +0 -2
- package/src/components/Radio/index.js +0 -1
- package/src/components/ScrollView/_helpers/getElementsPositionDifference.js +0 -11
- package/src/components/ScrollView/index.js +0 -1
- package/src/components/SelectField/SelectField.jsx +0 -272
- package/src/components/SelectField/_components/Option/Option.jsx +0 -46
- package/src/components/SelectField/_components/Option/index.js +0 -1
- package/src/components/SelectField/index.js +0 -1
- package/src/components/Table/_components/TableBodyCell/TableBodyCell.jsx +0 -46
- package/src/components/Table/_components/TableBodyCell/index.js +0 -1
- package/src/components/Table/_components/TableHeaderCell/index.js +0 -1
- package/src/components/Table/index.js +0 -1
- package/src/components/Tabs/TabsItem.jsx +0 -91
- package/src/components/Tabs/index.js +0 -2
- package/src/components/Text/Text.jsx +0 -76
- package/src/components/Text/_helpers/getRootClampClassName.js +0 -11
- package/src/components/Text/_helpers/getRootHyphensClassName.js +0 -11
- package/src/components/Text/_helpers/getRootWordWrappingClassName.js +0 -11
- package/src/components/Text/index.js +0 -1
- package/src/components/TextArea/TextArea.jsx +0 -174
- package/src/components/TextArea/index.js +0 -1
- package/src/components/TextField/TextField.jsx +0 -208
- package/src/components/TextField/index.js +0 -1
- package/src/components/TextLink/index.js +0 -1
- package/src/components/Toggle/Toggle.jsx +0 -144
- package/src/components/Toggle/index.js +0 -1
- package/src/components/Toolbar/Toolbar.jsx +0 -76
- package/src/components/Toolbar/ToolbarGroup.jsx +0 -64
- package/src/components/_helpers/resolveContextOrProp.js +0 -10
- package/src/helpers/isChildrenEmpty/isChildrenEmpty.js +0 -3
- package/src/helpers/transferProps/transferProps.js +0 -38
- package/src/index.js +0 -67
- package/src/providers/globalProps/GlobalPropsContext.jsx +0 -5
- package/src/providers/globalProps/withGlobalProps.jsx +0 -38
- package/src/providers/translations/TranslationsContext.jsx +0 -6
- package/src/utils/mergeDeep.js +0 -28
- package/tsconfig.json +0 -27
- /package/src/helpers/classNames/{index.js → index.ts} +0 -0
- /package/src/helpers/isChildrenEmpty/{index.js → index.ts} +0 -0
- /package/src/helpers/transferProps/{index.js → index.ts} +0 -0
package/CLAUDE.md
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
# CLAUDE.md
|
|
2
|
-
|
|
3
|
-
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository
|
|
4
|
-
|
|
5
|
-
## Environment
|
|
6
|
-
|
|
7
|
-
This project is developed inside a Docker container called `devcontainer`.
|
|
8
|
-
The commands below assume you are running inside the `devcontainer`.
|
|
9
|
-
|
|
10
|
-
From the host, run them inside it with
|
|
11
|
-
`docker compose exec -T devcontainer <command>` (start it first with
|
|
12
|
-
`docker compose up -d`). The other service containers (`node`, `playwright`,
|
|
13
|
-
`docs`) are implementation details — do not call them directly.
|
|
14
|
-
|
|
15
|
-
If file `/.dockerenv` is present, you are in a Docker container.
|
|
16
|
-
|
|
17
|
-
For details, see the
|
|
18
|
-
[Contributing Guide](src/docs/contribute/general-guidelines.md#development-environment).
|
|
19
|
-
|
|
20
|
-
## Commands
|
|
21
|
-
|
|
22
|
-
Run these inside the `devcontainer` (from the host, prefix with
|
|
23
|
-
`docker compose exec -T devcontainer`). For details, see the
|
|
24
|
-
[Contributing Guide](src/docs/contribute/general-guidelines.md).
|
|
25
|
-
|
|
26
|
-
| Task | Command |
|
|
27
|
-
|-----------------------------------|---------------------------------------------------------------------|
|
|
28
|
-
| Install JS | `npm ci` |
|
|
29
|
-
| Build library | `npm run build` |
|
|
30
|
-
| Run static checks | `npm run lint` |
|
|
31
|
-
| Run unit tests | `npm run test:jest` |
|
|
32
|
-
| Run a single unit test file | `npm run test:jest:ts -- <file>` / `npm run test:jest:js -- <file>` |
|
|
33
|
-
| Run component tests | `npm run test:playwright-ct:all` |
|
|
34
|
-
| Component tests for one component | `npm run test:playwright-ct:all -- -- src/components/Button` |
|
|
35
|
-
| Update component snapshots | `npm run test:playwright-ct:all-with-update` |
|
|
36
|
-
| Start build watcher | `npm start` |
|
|
37
|
-
| Build documentation | `mkdocs build` |
|
|
38
|
-
| Serve documentation | `mkdocs serve` |
|
|
39
|
-
|
|
40
|
-
Notes:
|
|
41
|
-
|
|
42
|
-
* Commands like `npm`, `playwright` run in specific Docker containers.
|
|
43
|
-
Normally, when you run those commands, they are executed within dedicated
|
|
44
|
-
containers. If you need to communicate directly with specific Docker container,
|
|
45
|
-
use `sudo docker compose ...`. It can be useful when stopping server that is
|
|
46
|
-
running within `node` container even though it is started from `devcontainer`.
|
|
47
|
-
* See the `scripts` section in `package.json` for the full list of commands.
|
|
48
|
-
|
|
49
|
-
## Topics (Claude Rules)
|
|
50
|
-
|
|
51
|
-
Project rules live in [.claude/rules/](.claude/rules/). There are two kinds.
|
|
52
|
-
|
|
53
|
-
**Always-on** (no frontmatter) — apply to every change:
|
|
54
|
-
|
|
55
|
-
* [code.md](.claude/rules/code.md) — scope discipline, minimal changes.
|
|
56
|
-
* [git.md](.claude/rules/git.md) — branches, commits, PRs.
|
|
57
|
-
* [safety-guards.md](.claude/rules/safety-guards.md) — hard guard rails.
|
|
58
|
-
|
|
59
|
-
**Path-scoped** — each carries a `paths:` glob declaring the files it governs;
|
|
60
|
-
consult it when touching those files:
|
|
61
|
-
|
|
62
|
-
* [frontend.md](.claude/rules/frontend.md) — `src/**/*.js`, `src/**/*.jsx`:
|
|
63
|
-
stack, component structure, implementation pattern.
|
|
64
|
-
* [styling.md](.claude/rules/styling.md) — `src/**/*.scss`, `src/**/*.css`:
|
|
65
|
-
CSS Modules, class naming, theming.
|
|
66
|
-
* [testing.md](.claude/rules/testing.md) — `*.spec.tsx`, `*.story.tsx`,
|
|
67
|
-
`__tests__/**`, `tests/**`: Jest and table-driven Playwright tests.
|
|
68
|
-
* [docs.md](.claude/rules/docs.md) — `src/docs/**`, component `README.md`.
|
|
69
|
-
|
|
70
|
-
## Agents (Claude Agents)
|
|
71
|
-
|
|
72
|
-
Specialized agents live in [.claude/agents/](.claude/agents/).
|
|
73
|
-
|
|
74
|
-
* `code-reviewer` — review a change against this repo's rules (uncommitted work,
|
|
75
|
-
or a whole branch vs its base).
|
|
76
|
-
|
|
77
|
-
## AI Integration
|
|
78
|
-
|
|
79
|
-
MCP-capable assistants in the `devcontainer` can drive host Chrome to verify the
|
|
80
|
-
docs site and rendered components. See
|
|
81
|
-
[AI Integration](src/docs/contribute/ai-integration.md) and
|
|
82
|
-
[scripts/mcps/chrome-host/README.md](scripts/mcps/chrome-host/README.md).
|
package/docker-compose.base.yml
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
services:
|
|
2
|
-
# This service is responsible for providing the main development environment for developers
|
|
3
|
-
devcontainer:
|
|
4
|
-
hostname: ${COMPOSE_PROJECT_NAME:-react-ui}_devcontainer
|
|
5
|
-
build:
|
|
6
|
-
context: docker/react_ui_devcontainer/
|
|
7
|
-
dockerfile: Dockerfile
|
|
8
|
-
# Start dependent services before starting the `devcontainer` service to ensure that the necessary environments
|
|
9
|
-
# and tools are available when the `devcontainer` starts.
|
|
10
|
-
depends_on:
|
|
11
|
-
node:
|
|
12
|
-
condition: service_started
|
|
13
|
-
playwright:
|
|
14
|
-
condition: service_started
|
|
15
|
-
docs:
|
|
16
|
-
condition: service_started
|
|
17
|
-
# Run as host UID/GID so files created in mounted volumes are owned correctly on the host.
|
|
18
|
-
# The images use `fixuid` (https://github.com/boxboat/fixuid) to remap the built-in `developer`
|
|
19
|
-
# user to these IDs at startup — the `user:` directive is required for that remap to work.
|
|
20
|
-
# Applied to all services below for the same reason.
|
|
21
|
-
user: ${COMPOSE_UID}:${COMPOSE_GID}
|
|
22
|
-
# Keep the container running indefinitely to allow developers to attach to it and use it as their development environment
|
|
23
|
-
command: sleep infinity
|
|
24
|
-
# Injects environment variables from the `.env` file into the `devcontainer` service,
|
|
25
|
-
# making them accessible within the container's environment.
|
|
26
|
-
env_file:
|
|
27
|
-
- .env
|
|
28
|
-
environment:
|
|
29
|
-
# This must be set correctly for the `devcontainer` to be able to access the host's Docker daemon,
|
|
30
|
-
# enabling Docker-from-Docker capabilities (e.g., running Docker commands from within the `devcontainer`).
|
|
31
|
-
COMPOSE_PROJECT_NAME: ${COMPOSE_PROJECT_NAME:-react-ui}
|
|
32
|
-
init: true
|
|
33
|
-
volumes:
|
|
34
|
-
- .:/workspace:z
|
|
35
|
-
# The following volume is used to allow the `devcontainer` to access the host's Docker daemon,
|
|
36
|
-
# enabling Docker-from-Docker capabilities (e.g., running Docker commands from within the `devcontainer`).
|
|
37
|
-
- /var/run/docker.sock:/var/run/docker.sock
|
|
38
|
-
# The following named volumes persist data (e.g. terminal history, AI tools data, etc.) across container restarts.
|
|
39
|
-
# Using separate named volumes (instead of a single volume with subpaths) allows Docker to automatically
|
|
40
|
-
# seed the volume with data from the image on first use.
|
|
41
|
-
- terminal-history:/home/developer/.terminal_history
|
|
42
|
-
- claude-config:/home/developer/.config/claude
|
|
43
|
-
- claude-state:/home/developer/.local/state/claude
|
|
44
|
-
- copilot:/home/developer/.copilot
|
|
45
|
-
- copilot-config:/home/developer/.config/copilot
|
|
46
|
-
- opencode-config:/home/developer/.config/opencode
|
|
47
|
-
- opencode-share:/home/developer/.local/share/opencode
|
|
48
|
-
- opencode-state:/home/developer/.local/state/opencode
|
|
49
|
-
|
|
50
|
-
# This service provides Node environment and NPM
|
|
51
|
-
node:
|
|
52
|
-
build: docker/node
|
|
53
|
-
user: ${COMPOSE_UID}:${COMPOSE_GID}
|
|
54
|
-
entrypoint: sh -c 'if [ "$$COMPOSE_AUTOSTART" = "true" ]; then sh scripts/auto-start-node.sh; else sleep infinity; fi'
|
|
55
|
-
env_file:
|
|
56
|
-
- .env
|
|
57
|
-
volumes:
|
|
58
|
-
- .:/workspace:z
|
|
59
|
-
|
|
60
|
-
# This service provides Playwright environment and tools for browser automation and testing
|
|
61
|
-
playwright:
|
|
62
|
-
build: docker/playwright
|
|
63
|
-
user: ${COMPOSE_UID}:${COMPOSE_GID}
|
|
64
|
-
command: sleep infinity
|
|
65
|
-
env_file:
|
|
66
|
-
- .env
|
|
67
|
-
ports:
|
|
68
|
-
- ${COMPOSE_PLAYWRIGHT_REPORT_PORT}:9323
|
|
69
|
-
volumes:
|
|
70
|
-
- .:/workspace:z
|
|
71
|
-
|
|
72
|
-
# This provides server for documentation
|
|
73
|
-
docs:
|
|
74
|
-
build: docker/mkdocs
|
|
75
|
-
user: ${COMPOSE_UID}:${COMPOSE_GID}
|
|
76
|
-
entrypoint: sh -c 'if [ "$$COMPOSE_AUTOSTART" = "true" ]; then sh scripts/auto-start-mkdocs.sh; else sleep infinity; fi'
|
|
77
|
-
env_file:
|
|
78
|
-
- .env
|
|
79
|
-
ports:
|
|
80
|
-
- ${COMPOSE_DOCS_SERVER_PORT}:8000
|
|
81
|
-
volumes:
|
|
82
|
-
- .:/workspace:z
|
|
83
|
-
|
|
84
|
-
volumes:
|
|
85
|
-
# The following volumes are used to persist data (e.g. terminal history, AI tools data, etc.) across container restarts
|
|
86
|
-
terminal-history:
|
|
87
|
-
claude-config:
|
|
88
|
-
claude-state:
|
|
89
|
-
copilot:
|
|
90
|
-
copilot-config:
|
|
91
|
-
opencode-config:
|
|
92
|
-
opencode-share:
|
|
93
|
-
opencode-state:
|
package/docker-compose.yml.dist
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
services:
|
|
2
|
-
# This service is responsible for providing the main development environment for developers
|
|
3
|
-
devcontainer:
|
|
4
|
-
extends:
|
|
5
|
-
file: docker-compose.base.yml
|
|
6
|
-
service: devcontainer
|
|
7
|
-
# Use `build` when you want to customize the devcontainer using `docker/react_ui_devcontainer_local/Dockerfile`
|
|
8
|
-
# build:
|
|
9
|
-
# context: ./docker/react_ui_devcontainer_local/
|
|
10
|
-
# dockerfile: Dockerfile
|
|
11
|
-
# Use `image` when you want to use the default devcontainer
|
|
12
|
-
image: react-ui_devcontainer
|
|
13
|
-
|
|
14
|
-
# This service provides Node environment and NPM
|
|
15
|
-
node:
|
|
16
|
-
extends:
|
|
17
|
-
file: docker-compose.base.yml
|
|
18
|
-
service: node
|
|
19
|
-
|
|
20
|
-
# This service provides Playwright environment and tools for browser automation and testing
|
|
21
|
-
playwright:
|
|
22
|
-
extends:
|
|
23
|
-
file: docker-compose.base.yml
|
|
24
|
-
service: playwright
|
|
25
|
-
|
|
26
|
-
# This provides server for documentation
|
|
27
|
-
docs:
|
|
28
|
-
extends:
|
|
29
|
-
file: docker-compose.base.yml
|
|
30
|
-
service: docs
|
|
31
|
-
|
|
32
|
-
volumes:
|
|
33
|
-
# The following volumes are used to persist data (e.g. terminal history, AI tools data, etc.) across container restarts
|
|
34
|
-
terminal-history:
|
|
35
|
-
claude-config:
|
|
36
|
-
claude-state:
|
|
37
|
-
copilot:
|
|
38
|
-
copilot-config:
|
|
39
|
-
opencode-config:
|
|
40
|
-
opencode-share:
|
|
41
|
-
opencode-state:
|
package/jest.config-ts.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
module.exports = {
|
|
3
|
-
extensionsToTreatAsEsm: [
|
|
4
|
-
'.ts',
|
|
5
|
-
'.tsx',
|
|
6
|
-
],
|
|
7
|
-
moduleFileExtensions: [
|
|
8
|
-
'js',
|
|
9
|
-
'jsx',
|
|
10
|
-
'ts',
|
|
11
|
-
'tsx',
|
|
12
|
-
],
|
|
13
|
-
moduleNameMapper: {
|
|
14
|
-
'\\.scss$': 'identity-obj-proxy',
|
|
15
|
-
'\\.svg$': '<rootDir>/tests/jest/mocks/svgrMock.jsx',
|
|
16
|
-
},
|
|
17
|
-
preset: 'ts-jest',
|
|
18
|
-
setupFiles: [
|
|
19
|
-
'<rootDir>/tests/jest/setupJest.js',
|
|
20
|
-
],
|
|
21
|
-
setupFilesAfterEnv: [
|
|
22
|
-
],
|
|
23
|
-
testEnvironment: '@happy-dom/jest-environment',
|
|
24
|
-
testMatch: [
|
|
25
|
-
'**/*.test.{ts,tsx}',
|
|
26
|
-
],
|
|
27
|
-
transform: {
|
|
28
|
-
'^.+\\.(ts|tsx)$': [
|
|
29
|
-
'ts-jest',
|
|
30
|
-
{ useESM: true },
|
|
31
|
-
],
|
|
32
|
-
},
|
|
33
|
-
verbose: true,
|
|
34
|
-
};
|
package/opencode.json
DELETED
package/playwright-ct.config.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defineConfig,
|
|
3
|
-
devices,
|
|
4
|
-
} from '@playwright/experimental-ct-react';
|
|
5
|
-
import { parseEnvironment } from './tests/playwright/env/parseEnvironment';
|
|
6
|
-
|
|
7
|
-
const environment = parseEnvironment();
|
|
8
|
-
|
|
9
|
-
const isCI = !!process.env.CI;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @see https://playwright.dev/docs/test-configuration
|
|
13
|
-
*/
|
|
14
|
-
module.exports = defineConfig({
|
|
15
|
-
// Fail the build on CI if you accidentally left test.only in the source code
|
|
16
|
-
forbidOnly: isCI,
|
|
17
|
-
// Run tests in files in parallel
|
|
18
|
-
fullyParallel: true,
|
|
19
|
-
// Directory where the output generated by Playwright is stored
|
|
20
|
-
outputDir: './tests/playwright/.temp/playwright-ct-output/',
|
|
21
|
-
// Run tests for following projects
|
|
22
|
-
projects: [
|
|
23
|
-
{
|
|
24
|
-
name: 'chromium',
|
|
25
|
-
use: { ...devices['Desktop Chrome'] },
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
|
29
|
-
reporter: 'html',
|
|
30
|
-
// Retry failed tests once to eliminate flakiness
|
|
31
|
-
retries: 1,
|
|
32
|
-
// Directory where the snapshots are located
|
|
33
|
-
// (must be same as testDir to save snapshots in place where tests are located)
|
|
34
|
-
snapshotDir: './src/',
|
|
35
|
-
// Directory where the tests are located
|
|
36
|
-
testDir: './src/',
|
|
37
|
-
// Pattern to search for test files
|
|
38
|
-
testMatch: '*/*.spec.{ts,tsx}',
|
|
39
|
-
// Timeout for each test
|
|
40
|
-
timeout: 10 * 1000,
|
|
41
|
-
// Do not update snapshots automatically
|
|
42
|
-
updateSnapshots: 'none',
|
|
43
|
-
// Configuration for Playwright component testing
|
|
44
|
-
use: {
|
|
45
|
-
// Directory where the cache is stored
|
|
46
|
-
ctCacheDir: './tests/playwright/.temp/playwright-ct-cache',
|
|
47
|
-
// Port to use for Playwright component endpoint
|
|
48
|
-
ctPort: environment.CT_PORT,
|
|
49
|
-
// Directory where the templates are stored
|
|
50
|
-
ctTemplateDir: './tests/playwright/templates',
|
|
51
|
-
// Launch options for Playwright
|
|
52
|
-
launchOptions: {
|
|
53
|
-
args: [
|
|
54
|
-
'--use-gl=egl',
|
|
55
|
-
// # Must be set to `new` to enable new version of Chromium Headless to obtain correct snapshots
|
|
56
|
-
'--headless=new',
|
|
57
|
-
],
|
|
58
|
-
ignoreDefaultArgs: [
|
|
59
|
-
// # Must be ignored to enable new version of Chromium Headless to obtain correct snapshots
|
|
60
|
-
'--headless',
|
|
61
|
-
],
|
|
62
|
-
},
|
|
63
|
-
// Collect trace on all retries
|
|
64
|
-
trace: 'on-all-retries',
|
|
65
|
-
},
|
|
66
|
-
// Number of workers to use
|
|
67
|
-
workers: environment.WORKERS,
|
|
68
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
|
|
3
|
-
set -e
|
|
4
|
-
|
|
5
|
-
# File to read the hash of the package-lock.json
|
|
6
|
-
LOCK_HASH_FILE="node_modules/.package-lock-hash"
|
|
7
|
-
|
|
8
|
-
# Parent directory of the script
|
|
9
|
-
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
|
|
10
|
-
|
|
11
|
-
# Change to the parent directory of the script
|
|
12
|
-
cd "$SCRIPT_DIR/.."
|
|
13
|
-
|
|
14
|
-
# Install dependencies if node_modules is missing or out of date
|
|
15
|
-
CURRENT_HASH=$(sha256sum package-lock.json | awk '{print $1}')
|
|
16
|
-
if [ ! -d "node_modules" ]; then
|
|
17
|
-
echo "Installing dependencies (node_modules directory is missing)..."
|
|
18
|
-
npm ci
|
|
19
|
-
elif [ ! -f "$LOCK_HASH_FILE" ]; then
|
|
20
|
-
echo "Installing dependencies (lockfile of package-lock.json is missing)..."
|
|
21
|
-
npm ci
|
|
22
|
-
elif [ "$(cat "$LOCK_HASH_FILE")" != "$CURRENT_HASH" ]; then
|
|
23
|
-
echo "Installing dependencies (package-lock.json has changed)..."
|
|
24
|
-
npm ci
|
|
25
|
-
fi
|
|
26
|
-
|
|
27
|
-
# Build the application (must be run prior to starting the server to ensure the latest code is used)
|
|
28
|
-
echo "Building the application..."
|
|
29
|
-
npm run build
|
|
30
|
-
|
|
31
|
-
# Start the application
|
|
32
|
-
echo "Starting the application..."
|
|
33
|
-
npm start
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
# Chrome-host bridge
|
|
2
|
-
|
|
3
|
-
Lets an MCP-capable AI assistant in the `devcontainer` drive **Chrome on the
|
|
4
|
-
host** via [`chrome-devtools-mcp`](https://github.com/ChromeDevTools/chrome-devtools-mcp)
|
|
5
|
-
over the Chrome DevTools Protocol (CDP).
|
|
6
|
-
|
|
7
|
-
## Principles
|
|
8
|
-
|
|
9
|
-
- The container reaches the host only via `host.docker.internal`.
|
|
10
|
-
- Chrome's DevTools endpoint rejects any `Host` header that is not an IP literal
|
|
11
|
-
(or the name `localhost`) — so the container cannot connect to it directly.
|
|
12
|
-
- Fix: a loopback proxy **inside the container** (`127.0.0.1:9334`); the `Host`
|
|
13
|
-
Chrome finally sees is `127.0.0.1`, an IP, which it accepts.
|
|
14
|
-
- Chrome runs in a dedicated, persistent profile (separate from your everyday
|
|
15
|
-
one) and is started **by hand** on the host — never from a Claude action,
|
|
16
|
-
which can reap it with its process group.
|
|
17
|
-
|
|
18
|
-
## Architecture
|
|
19
|
-
|
|
20
|
-
```text
|
|
21
|
-
Claude (devcontainer)
|
|
22
|
-
│ .mcp.json → mcp-entry.sh → docker compose exec node mcp-launch.sh
|
|
23
|
-
▼
|
|
24
|
-
node container
|
|
25
|
-
├─ cdp_proxy.py 127.0.0.1:9334 ──► host.docker.internal:9333
|
|
26
|
-
└─ npx chrome-devtools-mcp --browser-url http://127.0.0.1:9334
|
|
27
|
-
│
|
|
28
|
-
▼
|
|
29
|
-
host: Chrome --remote-debugging-port=9333 (throwaway profile)
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
| Script | Runs on | Purpose |
|
|
33
|
-
| --- | --- | --- |
|
|
34
|
-
| `start-host-chrome.sh` | host | Launch the debug Chrome on `:9333`. Idempotent; auto-detects Chrome/Chromium/Edge. On native Docker, also runs an `ncat` forwarder to expose `:9333` on the bridge gateway. |
|
|
35
|
-
| `cdp_proxy.py` | node container | Loopback CDP proxy `:9334` → host `:9333`. Binds-or-exits. |
|
|
36
|
-
| `mcp-launch.sh` | node container | Ensure the proxy is up, then `exec` `chrome-devtools-mcp`. |
|
|
37
|
-
| `mcp-entry.sh` | host / devcontainer | The `.mcp.json` command; routes into the node container (adds `sudo` inside the container). |
|
|
38
|
-
| `mcp-setup.sh` | host (setup) | Add the `host.docker.internal:host-gateway` mapping on native Docker Engine. Idempotent; no-op on Docker Desktop. |
|
|
39
|
-
|
|
40
|
-
## Registration
|
|
41
|
-
|
|
42
|
-
Register `mcp-entry.sh` as an MCP server named `chrome-host`. Any MCP client
|
|
43
|
-
works — point its config at the script.
|
|
44
|
-
|
|
45
|
-
**Claude / GitHub Copilot CLI** — `.mcp.json` (repo root):
|
|
46
|
-
|
|
47
|
-
```json
|
|
48
|
-
{
|
|
49
|
-
"mcpServers": {
|
|
50
|
-
"chrome-host": {
|
|
51
|
-
"command": "sh",
|
|
52
|
-
"args": ["scripts/mcps/chrome-host/mcp-entry.sh"]
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
**OpenCode** — `opencode.json` (repo root):
|
|
59
|
-
|
|
60
|
-
```json
|
|
61
|
-
{
|
|
62
|
-
"mcp": {
|
|
63
|
-
"chrome-host": {
|
|
64
|
-
"type": "local",
|
|
65
|
-
"command": ["sh", "scripts/mcps/chrome-host/mcp-entry.sh"],
|
|
66
|
-
"enabled": true
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
Requirements: a `docker-compose.yml` at the repo root, the repo mounted at
|
|
73
|
-
`/workspace` in the container, and a Compose service named `node` that runs
|
|
74
|
-
`node`/`npx`.
|
|
75
|
-
|
|
76
|
-
## Usage
|
|
77
|
-
|
|
78
|
-
1. Start host Chrome (from a host terminal, **not** from inside an AI action):
|
|
79
|
-
|
|
80
|
-
```sh
|
|
81
|
-
./scripts/mcps/chrome-host/start-host-chrome.sh
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
2. On first run, approve the `chrome-host` server in your MCP client.
|
|
85
|
-
|
|
86
|
-
The proxy and MCP server are bootstrapped by `mcp-launch.sh`; you only start
|
|
87
|
-
Chrome by hand.
|
|
88
|
-
|
|
89
|
-
## Platform support
|
|
90
|
-
|
|
91
|
-
Decided by **Docker Desktop vs native Docker Engine**, not the OS.
|
|
92
|
-
|
|
93
|
-
| Host setup | `host.docker.internal` reaches host loopback? | Extra steps |
|
|
94
|
-
| --- | --- | --- |
|
|
95
|
-
| Docker Desktop (macOS/Linux) | Yes (auto) | None. |
|
|
96
|
-
| Native Docker Engine (Linux) | No (bridge gateway only) | `setup.sh` (via `mcp-setup.sh`) adds the host-gateway mapping; the launcher runs a host-side `ncat` forwarder (install `nmap-ncat`/`nmap`) to expose Chrome's loopback CDP port on the bridge gateway. **Firewall the port**: this exposes DevTools beyond loopback. |
|
|
97
|
-
|
|
98
|
-
## Configuration
|
|
99
|
-
|
|
100
|
-
- Ports: host CDP `9333` (configurable), in-container proxy `9334` (fixed).
|
|
101
|
-
- Overrides (host launcher), set in the repo `.env`: `CHROME_DEBUG_PORT` and
|
|
102
|
-
`CHROME_BIN`. `CHROME_DEBUG_BIND` is an advanced escape hatch — the bind is
|
|
103
|
-
auto-detected, so it is not listed in `.env.dist`; set it only when detection
|
|
104
|
-
fails (e.g. a non-default daemon `host-gateway-ip`). **Security:** a
|
|
105
|
-
non-loopback bind exposes the unauthenticated CDP port; firewall it.
|
|
106
|
-
The proxy's listen port and target host are fixed constants; only its upstream
|
|
107
|
-
port is configurable, and it follows the same `CHROME_DEBUG_PORT`.
|
|
108
|
-
- Set these in the repo `.env`; Compose passes `CHROME_DEBUG_PORT` into the
|
|
109
|
-
container, so a single knob drives both sides. Recreate the node container
|
|
110
|
-
after editing. See `.env.dist`.
|
|
111
|
-
- Profile: `~/.chrome-debug-profile-<COMPOSE_PROJECT_NAME>` (per project, fixed).
|
|
112
|
-
|
|
113
|
-
## Troubleshooting
|
|
114
|
-
|
|
115
|
-
- Status: `claude mcp get chrome-host` (`✔ Connected` = healthy chain).
|
|
116
|
-
- Chrome died? Re-run `start-host-chrome.sh` (it persists across sessions).
|
|
117
|
-
- `claude mcp list` shows *Pending approval* until you approve project servers.
|
|
118
|
-
- Disable: remove the `chrome-host` entry from `.mcp.json`.
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import socket
|
|
3
|
-
import threading
|
|
4
|
-
|
|
5
|
-
# Loopback CDP proxy. Runs INSIDE the node container.
|
|
6
|
-
#
|
|
7
|
-
# A container reaches host Chrome only via `host.docker.internal` (forwarded to
|
|
8
|
-
# the host loopback on Docker Desktop; the bridge gateway on native Linux Docker,
|
|
9
|
-
# where a host-side ncat forwarder exposes Chrome's loopback CDP port). But
|
|
10
|
-
# Chrome's DevTools endpoint rejects any Host header that isn't an IP literal (or
|
|
11
|
-
# the name "localhost") -- anti DNS-rebinding -- so connecting by that *name*
|
|
12
|
-
# fails, and the IPv6 it may also resolve to is often not forwarded.
|
|
13
|
-
#
|
|
14
|
-
# So this proxy listens on 127.0.0.1:LISTEN_PORT and forwards raw bytes to host
|
|
15
|
-
# Chrome. Clients reach it as "127.0.0.1:LISTEN_PORT", so the Host header Chrome
|
|
16
|
-
# sees is an IP (accepted), and the webSocketDebuggerUrl it echoes back stays on
|
|
17
|
-
# 127.0.0.1 too, so the follow-up WebSocket also works.
|
|
18
|
-
#
|
|
19
|
-
# The proxy's own endpoint is fixed: it always listens on the container loopback
|
|
20
|
-
# and forwards to host Chrome over host.docker.internal. Only the upstream Chrome
|
|
21
|
-
# port is configurable, via CHROME_DEBUG_PORT (set in the repo's .env, which
|
|
22
|
-
# Compose passes into the container), so a single knob keeps both sides in sync.
|
|
23
|
-
|
|
24
|
-
LISTEN_HOST = "127.0.0.1"
|
|
25
|
-
LISTEN_PORT = 9334 # fixed; must match PROXY_PORT in mcp-launch.sh
|
|
26
|
-
TARGET_HOST = "host.docker.internal" # fixed; how the container reaches the host
|
|
27
|
-
TARGET_PORT = int(os.environ.get("CHROME_DEBUG_PORT") or "9333") # host Chrome CDP port
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def resolve_target():
|
|
31
|
-
# Force IPv4: host.docker.internal may also resolve to an IPv6 address that
|
|
32
|
-
# Docker does not forward to the host.
|
|
33
|
-
try:
|
|
34
|
-
infos = socket.getaddrinfo(TARGET_HOST, TARGET_PORT, socket.AF_INET, socket.SOCK_STREAM)
|
|
35
|
-
return infos[0][4]
|
|
36
|
-
except Exception:
|
|
37
|
-
# Docker Desktop's well-known host-gateway IPv4 as a last resort.
|
|
38
|
-
return ("192.168.65.254", TARGET_PORT)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
TARGET = resolve_target()
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
def pipe(source, destination):
|
|
45
|
-
try:
|
|
46
|
-
while True:
|
|
47
|
-
data = source.recv(65536)
|
|
48
|
-
if not data:
|
|
49
|
-
break
|
|
50
|
-
destination.sendall(data)
|
|
51
|
-
except Exception:
|
|
52
|
-
pass
|
|
53
|
-
finally:
|
|
54
|
-
for sock in (source, destination):
|
|
55
|
-
try:
|
|
56
|
-
sock.close()
|
|
57
|
-
except Exception:
|
|
58
|
-
pass
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
def handle(client):
|
|
62
|
-
try:
|
|
63
|
-
upstream = socket.create_connection(TARGET, timeout=10)
|
|
64
|
-
except Exception:
|
|
65
|
-
client.close()
|
|
66
|
-
return
|
|
67
|
-
threading.Thread(target=pipe, args=(client, upstream), daemon=True).start()
|
|
68
|
-
threading.Thread(target=pipe, args=(upstream, client), daemon=True).start()
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
def main():
|
|
72
|
-
srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
73
|
-
srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
|
74
|
-
try:
|
|
75
|
-
srv.bind((LISTEN_HOST, LISTEN_PORT))
|
|
76
|
-
except OSError:
|
|
77
|
-
# Another instance already owns the port; let it serve.
|
|
78
|
-
raise SystemExit(0)
|
|
79
|
-
srv.listen(128)
|
|
80
|
-
print("chrome-host: proxy listening %s:%d -> %s:%d" % (LISTEN_HOST, LISTEN_PORT, TARGET[0], TARGET[1]), flush=True)
|
|
81
|
-
while True:
|
|
82
|
-
try:
|
|
83
|
-
conn, _ = srv.accept()
|
|
84
|
-
except Exception:
|
|
85
|
-
continue
|
|
86
|
-
handle(conn)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if __name__ == "__main__":
|
|
90
|
-
main()
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
|
|
3
|
-
# Referenced by .mcp.json / opencode.json as the `chrome-host` MCP server command.
|
|
4
|
-
#
|
|
5
|
-
# Spawns chrome-devtools-mcp inside the node container (via mcp-launch.sh),
|
|
6
|
-
# whether the assistant runs in the devcontainer or on the host. Docker needs
|
|
7
|
-
# `sudo` inside the container (like the node/npx wrappers) but not on the host;
|
|
8
|
-
# we tell them apart by /.dockerenv, which exists only in a container.
|
|
9
|
-
|
|
10
|
-
set -eu
|
|
11
|
-
|
|
12
|
-
# Compose service that runs the proxy + chrome-devtools-mcp.
|
|
13
|
-
DOCKER_SERVICE_NAME=node
|
|
14
|
-
|
|
15
|
-
script_dir="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
|
|
16
|
-
|
|
17
|
-
# Walk up to the repo root (the directory holding docker-compose.yml) so
|
|
18
|
-
# `docker compose` finds the compose files + .env regardless of the caller's cwd.
|
|
19
|
-
root="$script_dir"
|
|
20
|
-
while [ "$root" != "/" ] && [ ! -f "$root/docker-compose.yml" ]; do
|
|
21
|
-
root="$(dirname "$root")"
|
|
22
|
-
done
|
|
23
|
-
cd "$root"
|
|
24
|
-
|
|
25
|
-
# Path to mcp-launch.sh as seen inside the node container (repo mounted at /workspace).
|
|
26
|
-
rel="${script_dir#"$root"/}"
|
|
27
|
-
launch="/workspace/$rel/mcp-launch.sh"
|
|
28
|
-
|
|
29
|
-
if [ -f /.dockerenv ]; then
|
|
30
|
-
exec sudo docker compose exec -T "$DOCKER_SERVICE_NAME" "$launch"
|
|
31
|
-
else
|
|
32
|
-
exec docker compose exec -T "$DOCKER_SERVICE_NAME" "$launch"
|
|
33
|
-
fi
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
|
|
3
|
-
# Runs INSIDE the node container, invoked by mcp-entry.sh.
|
|
4
|
-
#
|
|
5
|
-
# Ensures the loopback CDP proxy (cdp_proxy.py) is running, then hands stdio over
|
|
6
|
-
# to chrome-devtools-mcp pointed at the proxy. Resolves cdp_proxy.py next to
|
|
7
|
-
# itself, so it works from any location under the repo.
|
|
8
|
-
|
|
9
|
-
set -eu
|
|
10
|
-
|
|
11
|
-
SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
|
|
12
|
-
PROXY_PORT=9334 # fixed; must match LISTEN_PORT in cdp_proxy.py
|
|
13
|
-
PROXY_SCRIPT="$SCRIPT_DIR/cdp_proxy.py"
|
|
14
|
-
|
|
15
|
-
is_up() {
|
|
16
|
-
python3 -c 'import socket,sys; s=socket.socket(); sys.exit(0 if s.connect_ex(("127.0.0.1",'"$PROXY_PORT"'))==0 else 1)' 2>/dev/null
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if ! is_up; then
|
|
20
|
-
# cdp_proxy.py binds-or-exits, so concurrent launches are safe.
|
|
21
|
-
python3 "$PROXY_SCRIPT" >/tmp/cdp_proxy.log 2>&1 &
|
|
22
|
-
i=0
|
|
23
|
-
while [ "$i" -lt 25 ]; do
|
|
24
|
-
if is_up; then
|
|
25
|
-
break
|
|
26
|
-
fi
|
|
27
|
-
i=$((i + 1))
|
|
28
|
-
sleep 0.2
|
|
29
|
-
done
|
|
30
|
-
fi
|
|
31
|
-
|
|
32
|
-
# chrome-devtools-mcp is fetched on demand via npx rather than being added to
|
|
33
|
-
# package.json: it is host/dev MCP tooling for this bridge, not an app build or
|
|
34
|
-
# runtime dependency, so it deliberately stays out of the lockfile. `-y` confirms
|
|
35
|
-
# the one-off npx install; `@latest` tracks upstream fixes for the dev tool.
|
|
36
|
-
exec npx -y chrome-devtools-mcp@latest --browser-url "http://127.0.0.1:${PROXY_PORT}" "$@"
|