@gears-frontx/react 0.2.0-alpha.0 → 0.2.0-alpha.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.
@@ -1,153 +0,0 @@
1
- <!-- @standalone -->
2
- # frontx:new-mfe - Create New Microfrontend Package
3
-
4
- ## PREREQUISITES (CRITICAL - STOP IF FAILED)
5
-
6
- 1. MFE must be associated with a screenset
7
- 2. Screenset must exist (run `frontx-new-screenset` first if needed)
8
- 3. Vite and Module Federation must be configured
9
-
10
- ## QUICK START
11
-
12
- For a screenset named `{screensetName}` with a new MFE:
13
-
14
- ```bash
15
- # 1. Create the MFE package in src/mfe_packages/{screensetName}-mfe/
16
- cp -r packages/cli/template-sources/mfe-package/ src/mfe_packages/{screensetName}-mfe/
17
-
18
- # 2. Update variables in package.json and vite.config.ts:
19
- # - Replace {{mfeName}} with your screenset name (camelCase)
20
- # - Replace {{port}} with available port (3001, 3010, 3020, etc)
21
- # - IMPORTANT: set preview script to "vite preview --port {{port}}"
22
-
23
- # 3. Install dependencies
24
- cd src/mfe_packages/{screensetName}-mfe
25
- npm install
26
-
27
- # 4. Create src/lifecycle.tsx that extends ThemeAwareReactLifecycle
28
-
29
- # 5. Regenerate MFE manifests so bootstrap.ts picks up the new package
30
- npm run generate:mfe-manifests
31
- ```
32
-
33
- ## CONFIGURATION REQUIREMENTS
34
-
35
- ✅ **Correct preview script** (required for port auto-discovery):
36
- ```json
37
- "preview": "vite preview --port {{port}}"
38
- ```
39
-
40
- ✅ **Correct dev script** (for hot reload):
41
- ```json
42
- "dev": "vite --port {{port}}"
43
- ```
44
-
45
- ❌ **WRONG** (don't use this for dev):
46
- ```json
47
- "dev": "vite build && vite preview --port {{port}}"
48
- ```
49
-
50
- ## PORT ALLOCATION
51
-
52
- Reserve ports for MFE packages:
53
- - **3001**: demo-mfe
54
- - **3010+**: (next available: 3010, 3020, 3030, ...)
55
- - **5173**: Main app
56
-
57
- ## LIFECYCLE TEMPLATE
58
-
59
- Create `src/lifecycle.tsx`:
60
-
61
- ```typescript
62
- import React from 'react';
63
- import type { ChildMfeBridge } from '@gears-frontx/react';
64
- import { ThemeAwareReactLifecycle } from '@gears-frontx/react';
65
- import { mfeApp } from './init';
66
- import { YourScreen } from './screens/YourScreen';
67
-
68
- class Lifecycle extends ThemeAwareReactLifecycle {
69
- constructor() {
70
- super(mfeApp);
71
- }
72
-
73
- protected renderContent(bridge: ChildMfeBridge): React.ReactNode {
74
- return <YourScreen bridge={bridge} />;
75
- }
76
- }
77
-
78
- export default new Lifecycle();
79
- ```
80
-
81
- ## dev:all INTEGRATION (AUTOMATIC)
82
-
83
- After creating the MFE and running `npm run generate:mfe-manifests`, the `dev:all`
84
- script auto-discovers your new package — no manual configuration needed.
85
-
86
- `dev-all.ts` scans `src/mfe_packages/*/package.json` and reads the port from the
87
- `preview` (or `dev`) script using `--port NNNN`. The new MFE will automatically
88
- appear in the next `npm run dev:all` run.
89
-
90
- ## VALIDATION
91
-
92
- After creation:
93
-
94
- ```bash
95
- # Regenerate manifests (required after adding new MFE)
96
- npm run generate:mfe-manifests
97
-
98
- # Validate TypeScript
99
- npm run type-check
100
-
101
- # Check architecture compliance
102
- npm run arch:check
103
-
104
- # Run the dev server (picks up new MFE automatically)
105
- npm run dev:all
106
-
107
- # Verify MFE loads at http://localhost:5173
108
- # Open Studio Overlay (Ctrl+`) and check screenset
109
- ```
110
-
111
- ## TROUBLESHOOTING
112
-
113
- ### Issue: MFE not appearing in screenset selector
114
- - Run `npm run generate:mfe-manifests` to regenerate manifests
115
- - Check mfe.json manifest is properly exported
116
- - Verify extensions are registered in manifest
117
- - Check browser console for errors
118
-
119
- ### Issue: dev:all not picking up MFE port
120
- - Verify `preview` script has `--port NNNN` (e.g., `"vite preview --port 3010"`)
121
- - Check port is not in use (`lsof -i :3010`)
122
- - Restart dev server
123
-
124
- ### Issue: Hot reload not working
125
- - Verify dev script uses `vite --port` (not `vite build && vite preview`)
126
- - Check port is not in use
127
- - Restart dev server
128
-
129
- ### Issue: Redux/useSelector errors
130
- - MFE must use mock data (no Redux Provider in isolation)
131
- - Use `useState` for local state management
132
- - Do not import Redux hooks (@gears-frontx/react)
133
-
134
- ## BEST PRACTICES
135
-
136
- ✅ **DO:**
137
- - Set `preview` script with `--port NNNN` for port auto-discovery
138
- - Use mock data with useState for UI-only MFEs
139
- - Keep MFE logic isolated and simple
140
- - Use local components (e.g. components/ui/)
141
- - Run `npm run generate:mfe-manifests` after creating the MFE
142
-
143
- ❌ **DON'T:**
144
- - Import Redux hooks directly
145
- - Use vite build && vite preview in dev mode
146
- - Create complex state management in MFE
147
- - Hardcode ports without updating package.json preview script
148
-
149
- ---
150
-
151
- See also:
152
- - `/packages/cli/template-sources/mfe-package/` for templates
153
- - `frontx-new-screenset.md` for screenset creation
@@ -1,45 +0,0 @@
1
- <!-- @standalone -->
2
- # frontx:new-screen - Add New Screen
3
-
4
- ## AI WORKFLOW (REQUIRED)
5
- 1) Read .ai/targets/SCREENSETS.md and .ai/targets/EVENTS.md before starting.
6
- 2) Read `.ai/project/GUIDELINES.md` and `.ai/project/targets/UNIT_TESTING.md` when they exist **before** planning unit tests, validation, or any test-related tasks in this command (project-owned overrides take precedence over defaults here).
7
- 3) Gather requirements from user (including UI sections).
8
- 4) Implement.
9
-
10
- ## GATHER REQUIREMENTS
11
- Ask user for:
12
- - Screenset path (e.g., src/screensets/chat).
13
- - Screen name (camelCase).
14
- - UI sections (e.g., "header, form, data table").
15
- - Add to menu? (Y/N)
16
-
17
- ## STEP 1: Implementation
18
- 1) Add screen ID to ids.ts.
19
- 2) Create components BEFORE screen file per Component Plan.
20
- 3) Create screen following data flow rules from .ai/targets/EVENTS.md:
21
- - Use actions to trigger state changes
22
- - FORBIDDEN: Direct slice dispatch from screen
23
- 4) Add i18n with useScreenTranslations(). Export default.
24
- 5) Add or update a screen test that covers stable render or behavior for the new screen and place any test-only helpers in a sibling `__test-utils__/` folder.
25
- 6) Add to menu if requested.
26
- 7) Validate: run `test:unit`, `type-check`, and `arch:check` via this project's package manager per `.ai/project/targets/UNIT_TESTING.md` (which defines the exact commands). Apply constraints from workflow step 2.
27
- 8) Test via Chrome DevTools MCP (REQUIRED):
28
- - Navigate to new screen
29
- - Verify screen renders without console errors
30
- - Test UI interactions and data flow
31
- - Verify translations load correctly
32
- - STOP if MCP connection fails
33
-
34
- ## TESTING
35
- - REQUIRED: Load `.ai/project/GUIDELINES.md` and `.ai/project/targets/UNIT_TESTING.md` when they exist **before** interpreting unit-test requirements elsewhere in this command.
36
- - REQUIRED: Use neutral fixtures, translation mocks, and stable keys, roles, or IDs instead of placeholder-derived copy when adding or updating generated screen tests.
37
-
38
- ## COMPONENT PLAN
39
- - REQUIRED: Use local components (e.g. `components/ui/`) — no shared UI kit package.
40
- - components/ui/: base UI primitives (shadcn components or custom)
41
- - screens/{screen}/components/: screen-specific components
42
-
43
- ## DATA FLOW
44
- - Uses existing screenset events/slices per EVENTS.md
45
- - Screen dispatches actions, never direct slice updates
@@ -1,57 +0,0 @@
1
- <!-- @standalone -->
2
- # frontx:new-screenset - Create New Screenset
3
-
4
- ## PREREQUISITES (CRITICAL - STOP IF FAILED)
5
- Run `frontx --version`.
6
- STOP: If fails, tell user to install.
7
- FORBIDDEN: Creating screenset manually or by copying peers.
8
-
9
- ## AI WORKFLOW (REQUIRED)
10
- 1) Check prerequisites above.
11
- 2) Read .ai/targets/SCREENSETS.md and .ai/targets/EVENTS.md before starting.
12
- 3) Read `.ai/project/GUIDELINES.md` and `.ai/project/targets/UNIT_TESTING.md` when they exist **before** planning unit tests, validation, or any test-related tasks in this command (project-owned overrides take precedence over defaults here).
13
- 4) Gather requirements from user (including UI sections).
14
- 5) Implement.
15
-
16
- ## GATHER REQUIREMENTS
17
- Ask user for:
18
- - Screenset name (camelCase).
19
- - Category: Drafts | Mockups | Production.
20
- - Initial screens.
21
- - UI sections per screen (e.g., "stats cards, charts, activity feed").
22
-
23
- ## STEP 1: Implementation
24
- 1) Create screenset via `frontx screenset create` (REQUIRED).
25
- 2) Create components BEFORE screen file per Component Plan.
26
- 3) Implement data flow per .ai/targets/EVENTS.md:
27
- - Actions emit events via eventBus.emit()
28
- - Effects subscribe and update slices
29
- - FORBIDDEN: Direct slice dispatch from components
30
- 4) Add API service with mocks and endpoint descriptors:
31
- - Read endpoints: `readonly prop = this.protocol(RestEndpointProtocol).query<T>('/path')`
32
- - Write endpoints: `readonly prop = this.protocol(RestEndpointProtocol).mutation<T, V>('PUT', '/path')`
33
- - NO queryOptions, NO manual query key factories outside the service
34
- - Screens use `useApiQuery(service.prop)` and `useApiMutation({ endpoint: service.prop })`
35
- 5) Add or update starter unit tests for stable generated behavior.
36
- 6) Validate: run `test:unit`, `type-check`, `arch:check`, and `lint` via this project's package manager per `.ai/project/targets/UNIT_TESTING.md` (which defines the exact commands). Apply constraints from workflow step 3.
37
- 7) Test via Chrome DevTools MCP (REQUIRED):
38
- - Navigate to new screenset
39
- - Verify screen renders without console errors
40
- - Test user interactions trigger correct events
41
- - Verify state updates via Redux DevTools
42
- - STOP if MCP connection fails
43
-
44
- ## COMPONENT PLAN
45
- - REQUIRED: Use local components (e.g. `components/ui/`) — no shared UI kit package.
46
- - components/ui/: base UI primitives (shadcn components or custom)
47
- - components/: multi-screen shared components
48
- - screens/{screen}/components/: screen-specific components
49
-
50
- ## DATA FLOW
51
- - Events: {domain events per EVENTS.md}
52
- - State: slices/, events/, effects/, actions/
53
- - API: api/{Name}ApiService.ts with mocks and endpoint descriptors
54
-
55
- ## TESTING
56
- - REQUIRED: Load `.ai/project/GUIDELINES.md` and `.ai/project/targets/UNIT_TESTING.md` when they exist **before** interpreting unit-test requirements elsewhere in this command.
57
- - REQUIRED: Preserve the generated API-contract test and `HomeScreen` smoke test unless the new behavior replaces that baseline intentionally.