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
40 changes: 31 additions & 9 deletions .ai/skills/saucebase-frontend-development/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,43 @@ Also read `.ai/rules/frontend.md` before editing under `resources/js/`.

## Module setup hooks

Each module's `resources/js/app` entry may export `setup()` and `afterMount()`.
Each module's `resources/js/<framework>/app` entry (`resources/js/app` once
installed) may export `setup()` and `afterMount()`. Vue entries are `app.ts`,
React entries `app.tsx`; core finds no other name.
Core imports every module's entry eagerly and runs all `setup()` calls before
the app mounts, then all `afterMount()` calls after it. Register everything a
module contributes in `setup()`:
the first render, then all `afterMount()` calls after the browser mounts. The
server renders the same app, so `setup()` runs there too: keep it to
registrations and put anything that touches `window`, `document` or storage in
`afterMount()`. Register everything a module contributes in `setup()`:

| Call | Purpose |
|---|---|
| `registerIcon(name, Component)` (`@saucebase/<framework>/lib/navigation`) | Icon for navigation items whose `icon` attribute is `name` |
| `registerAction(id, handler)` (`@saucebase/<framework>/lib/navigation`) | Click handler for navigation items whose `action` attribute is `id`; registering an id twice warns and replaces the first |
| `registerGlobalComponent(slot, Component)` (`@saucebase/<framework>/lib/globalComponents`) | Component rendered in a layout slot |

Slots: `top` and `bottom` wrap the page; `sidebar-brand` replaces the block
above the sidebar navigation; `user-subtitle` replaces the email under the
user's name in the sidebar user menu. A new slot needs a case in
`globalComponents` and a render in the layout that owns that region.
| `registerGlobalComponent(slot, Component, { order? })` (`@saucebase/<framework>/lib/globalComponents`) | Component rendered in a layout slot |

Slots are named `{area}::{region}.{position}`, like Filament's render hooks.
Areas: `app` (shell), `site` (public layout), `dashboard` (signed-in layout),
`home` (index page). `before`/`after` sit outside a region, `start`/`end`
inside it. The full list is `GlobalComponentSlots` in `@saucebase/core/types`:
`app::page.*`, `site::{header,content,footer}.*`, `home::content.*`,
`dashboard::{header,content}.*` and `dashboard::sidebar.{start,end}`.
`dashboard::sidebar.brand` replaces the brand above the sidebar navigation;
`dashboard::user-menu.subtitle` replaces the email in the user menu. Pass
`{ order }` (default 100, lower first) to sort components in a slot. A module
adds its own slot by augmenting `GlobalComponentSlots` and rendering
`<GlobalComponents position="…" />`.

## Server rendering

Pages that opt into SSR render on the server, then the browser hydrates that
HTML instead of rendering again. The first browser render must match it:

- Read `window`, `document` and storage in `onMounted()` / `useEffect()`, never
during setup or render; guard shared helpers with `typeof window`.
- Teleport or portal to `<body>` only after mount (`useMounted()` from VueUse,
a `mounted` state in React): the server can't render into `<body>`.
- Derive what renders from page props, which are the same on both sides.

## What a module may import

Expand Down
16 changes: 12 additions & 4 deletions .ai/skills/saucebase-testing/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,18 @@ npx playwright test --project="@auth*" # one module; core specs are "@Core*"

Run module suites with a 2048 MB memory limit, as `CONTRIBUTING.md` does.

Playwright project names are `@<module> [<device>]`, one per installed module,
so filter with a trailing `*`. Every project depends on
`database.setup`; a module can add setup projects in its own
`playwright.config.ts`.
`playwright.config.ts` gets every project from core's `saucebaseProjects()`:
`database.setup`, the modules' setups, then the app's own and one per installed
module, each per device. Project names are `@<module> [<device>]`, so filter
with a trailing `*`. Every project depends on `database.setup`. A module tunes its project from its own
`playwright.config.ts`, which exports `playwright`, an object typed
`satisfies ModulePlaywrightOptions` (`import type { ModulePlaywrightOptions } from '@saucebase/core/modules'`):

| Key | Purpose |
|---|---|
| `setups` | Setup projects the module's tests depend on, each with a `name` |
| `runAlone` | `true` when the tests change state the whole app shares (a site-wide setting): the project starts after every other one finishes, and run-alone projects run one at a time; it is skipped when another fails and runs on its own with `--no-deps` |
| `project` | Playwright options for the module's project (`use`, `timeout`, `retries`); core keeps its name, folder and dependencies |

## PHPUnit base class

Expand Down
3 changes: 3 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ includes:
tenancy:
taskfile: ./modules/tenancy/Taskfile.yml
optional: true
newsletter:
taskfile: ./modules/newsletter/Taskfile.yml
optional: true
# ── END MODULES ──────────────────────────────────────────────────

tasks:
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
"license": "MIT",
"require": {
"php": "^8.4",
"laravel/framework": "^13.37.0",
"laravel/framework": "^13.38.0",
"laravel/tinker": "^3.0.2",
"saucebase/core": "^1.14"
"saucebase/core": "^2.0"
},
"require-dev": {
"barryvdh/laravel-ide-helper": "^3.7",
"fakerphp/faker": "^1.24.1",
"kkomelin/laravel-translatable-string-exporter": "^1.26",
"larastan/larastan": "^3.13",
"larastan/larastan": "^3.13.1",
"laravel/boost": "^2.10.3",
"laravel/pail": "^1.2.7",
"laravel/pint": "^1.32.1",
Expand Down
Loading
Loading