Skip to content

Commit 5bcd475

Browse files
authored
Merge pull request #19 from Semantic-Org/refactor/layout
Refactor: Move the router to the top-level src, with plugins and integrations as their own packages
2 parents 4b5b7c9 + 3e83e1c commit 5bcd475

57 files changed

Lines changed: 545 additions & 415 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎README.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ app.start();
4747

4848
| Package | Description |
4949
| --- | --- |
50-
| [nav-router](packages/nav-router) | The router, its plugins and the reactive scaffold integrations build on |
51-
| [@nav-router/solid](packages/solid) | Nav Router for Solid |
50+
| [nav-router](src) | The router and the reactive scaffold integrations build on |
51+
| [@nav-router/plugins](packages/plugins) | The plugins, each installed by importing it |
52+
| [@nav-router/solid](integrations/solid) | Nav Router for Solid |
53+
| [@nav-router/core](packages/core) | The router under its scoped name, a thin re-export |
5254

5355
## Examples
5456

‎ai/integrations.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ If this page and the code are not enough to build on, the seam is wrong and not
1818
|---|---|---|
1919
| `Router` | the platform, the page, the cascade (guards, data, titles), the route lifecycle, the settings. Nothing of a route's, nothing of a view's. `router.root` is the root route | `packages/nav-router/src/router.js` |
2020
| `Route` | its data slice, its active life (an abort signal), its reactive runs, and what it shows under `rendered` | `packages/nav-router/src/route.js` |
21-
| a plugin | nothing. `import 'nav-router/plugins/x'` is the install, as a custom element's definition is: the module patches a moment on `Router.prototype` or `Navigator.prototype` once, at evaluation, and calls through; its options are the router's, declared on `Router.defaults` and read from `config`. Options are flat, each word qualified enough to stand alone in `router({...})`; a plugin that wants a namespace declares one object-valued key and merges what it is passed over its own defaults itself, since the router's merge is shallow | `packages/nav-router/src/plugins/*` |
21+
| a plugin | nothing. `import '@nav-router/plugins/x'` is the install, as a custom element's definition is: the module patches a moment on `Router.prototype` or `Navigator.prototype` once, at evaluation, and calls through; its options are the router's, declared on `Router.defaults` and read from `config`. Options are flat, each word qualified enough to stand alone in `router({...})`; a plugin that wants a namespace declares one object-valued key and merges what it is passed over its own defaults itself, since the router's merge is shallow | `packages/nav-router/src/plugins/*` |
2222
| the dom plugin | the native how for the three seams. The reference implementation of this page | `packages/nav-router/src/plugins/dom.js` |
2323
| `ReactiveRouter` | the scaffold a reactive integration extends: the five primitives, slices as per-key stores, hooks in reactions | `packages/nav-router/src/reactive-router.js` |
2424
| an integration | a class extending `Router` or `ReactiveRouter` that fills the seams, in its own package | `@nav-router/<name>` |

‎docs/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ npm run build # the sandbox, then the static site in dist/, then a Pagefind
1616
npm run preview # serve dist/, search uses Pagefind
1717
```
1818

19-
Plugin and core sizes are measured at build from `../packages/nav-router` (`src/lib/sizes.js`),
19+
Plugin and core sizes are measured at build from the repo root (`src/lib/sizes.js`),
2020
so they are always the package's own. A size that can't be measured fails the build.
2121

2222
Live examples (`/examples/`) run on `@semantic-ui/playground` from npm. `npm run sandbox` copies its

‎docs/scripts/sync-sandbox.mjs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { fileURLToPath } from 'node:url';
1212
const require = createRequire(import.meta.url);
1313
const here = dirname(fileURLToPath(import.meta.url));
1414
const pub = resolve(here, '../public');
15-
const NAV_ROUTER = resolve(here, '../../packages/nav-router');
15+
const NAV_ROUTER = resolve(here, '../..');
1616

1717
const copy = async (from, to) => {
1818
await fs.rm(to, { recursive: true, force: true });
@@ -23,6 +23,7 @@ const copy = async (from, to) => {
2323
const playgroundAssets = resolve(dirname(require.resolve('@semantic-ui/playground/package.json')), 'dist/assets');
2424
await copy(playgroundAssets, resolve(pub, 'sandbox'));
2525
await copy(resolve(NAV_ROUTER, 'src'), resolve(pub, 'libs/nav-router'));
26+
await copy(resolve(NAV_ROUTER, 'packages/plugins/src'), resolve(pub, 'libs/plugins'));
2627
// the package doesn't export its package.json, so it's found from its entry
2728
const utilsEntry = require.resolve('@semantic-ui/utils');
2829
const utilsDir = utilsEntry.slice(0, utilsEntry.lastIndexOf('@semantic-ui/utils') + '@semantic-ui/utils'.length);

‎docs/src/content/docs/plugins/head.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: head
33
kind: plugin
44
lede: Writes each page’s title, meta tags and canonical link into `document.head`, merged down the routes that are active.
5-
import: import 'nav-router/plugins/head'
5+
import: import '@nav-router/plugins/head'
66
size: head
77
updated: 2026-11-05
88
---
@@ -12,7 +12,7 @@ updated: 2026-11-05
1212
Import the plugin once. A plugin wraps one moment in the router and calls through, so importing it changes nothing else, and its options are the router's own.
1313

1414
```js title="app.js"
15-
import 'nav-router/plugins/head';
15+
import '@nav-router/plugins/head';
1616
import { router } from 'nav-router';
1717

1818
const app = router({

‎docs/src/content/examples/back-and-forward/app.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'nav-router/plugins/dom';
1+
import '@nav-router/plugins/dom';
22
import { router } from 'nav-router';
33

44
import { routes } from './routes.js';

‎docs/src/content/examples/first-router/app.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'nav-router/plugins/dom';
1+
import '@nav-router/plugins/dom';
22
import { router } from 'nav-router';
33

44
import { routes } from './routes.js';

‎docs/src/content/examples/guards/app.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'nav-router/plugins/dom';
1+
import '@nav-router/plugins/dom';
22
import { router } from 'nav-router';
33

44
import { routes } from './routes.js';

‎docs/src/content/examples/loading-states/app.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'nav-router/plugins/dom';
1+
import '@nav-router/plugins/dom';
22
import { router } from 'nav-router';
33

44
import { routes } from './routes.js';

‎docs/src/content/examples/not-found/app.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'nav-router/plugins/dom';
1+
import '@nav-router/plugins/dom';
22
import { router } from 'nav-router';
33

44
import { routes } from './routes.js';

0 commit comments

Comments
 (0)