@openelement/create 1.0.0-alpha.15 → 1.0.0-alpha.16
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 +23 -43
- package/package.json +1 -1
- package/src/template-builder.js +1 -7
- package/src/version.js +1 -1
- package/templates/AGENTS.md.tmpl +8 -6
- package/templates/README.tmpl +36 -186
- package/templates/app/islands/live-timer.tsx.tmpl +49 -53
- package/templates/app/islands/my-counter.tsx.tmpl +43 -43
- package/templates/app/layout.tsx.tmpl +64 -53
- package/templates/app/routes/404.tsx.tmpl +17 -2
- package/templates/app/routes/about.tsx.tmpl +34 -3
- package/templates/app/routes/index.tsx.tmpl +32 -3
- package/templates/app/styles/theme.css +19 -0
- package/templates/gitignore.tmpl +2 -0
- package/templates/package.json.tmpl +3 -3
- package/templates/tests/ping.test.ts.tmpl +15 -0
- package/templates/tsconfig.json.tmpl +1 -1
- package/templates/app/components/page-404.css +0 -5
- package/templates/app/components/page-404.tsx.tmpl +0 -27
- package/templates/app/components/page-about.css +0 -5
- package/templates/app/components/page-about.tsx.tmpl +0 -97
- package/templates/app/components/page-home.css +0 -5
- package/templates/app/components/page-home.tsx.tmpl +0 -155
- package/templates/app/components/site-chrome.css +0 -5
package/README.md
CHANGED
|
@@ -4,11 +4,7 @@ Project scaffolding CLI for openElement applications.
|
|
|
4
4
|
|
|
5
5
|
Docs and guides: <https://openelement.org>.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
> npm versions and dist-tags are registry truth (query them with
|
|
9
|
-
> `npm view @openelement/create dist-tags`); `latest` rides the 1.0 line since
|
|
10
|
-
> the alpha.11 ruling, so a versionless install resolves the current 1.0
|
|
11
|
-
> prerelease.
|
|
7
|
+
Use `npm view @openelement/create dist-tags` to check the published versions.
|
|
12
8
|
|
|
13
9
|
`@openelement/create` generates a new openElement project from ONE template —
|
|
14
10
|
the showcase starter: a static-first landing page with two islands, a fully
|
|
@@ -23,17 +19,23 @@ package explicitly.) The repository's own
|
|
|
23
19
|
development flow (Vite+ / `vp`) stays in this repository and appears nowhere in
|
|
24
20
|
the generated manifest or scripts.
|
|
25
21
|
|
|
26
|
-
## Usage
|
|
22
|
+
## Usage
|
|
27
23
|
|
|
28
24
|
```bash
|
|
29
25
|
npm create @openelement my-app
|
|
30
26
|
```
|
|
31
27
|
|
|
32
|
-
The CLI
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
The CLI installs dependencies with the invoking package manager, so the command
|
|
29
|
+
above uses npm even when pnpm is on `PATH`. On a direct CLI invocation with no
|
|
30
|
+
package manager identified, it checks `PATH` in pnpm, npm, yarn, bun order. You
|
|
31
|
+
can scaffold without any manager using `--no-install`. The handoff shows the
|
|
32
|
+
commands for the selected manager. The CLI also initializes git when available
|
|
33
|
+
and the target is outside an existing repository.
|
|
34
|
+
|
|
35
|
+
Start the dev server from the generated project. Edit the heading in
|
|
36
|
+
`app/routes/index.tsx` and save to see the home page update.
|
|
37
|
+
|
|
38
|
+
Optional flags
|
|
37
39
|
|
|
38
40
|
| Flag | Default | Meaning |
|
|
39
41
|
| --- | --- | --- |
|
|
@@ -64,23 +66,8 @@ Non-interactive runs (CI, packed consumers) behave identically.
|
|
|
64
66
|
npx @openelement/create my-app --no-install --no-git -t showcase
|
|
65
67
|
```
|
|
66
68
|
|
|
67
|
-
`npm create @openelement`
|
|
68
|
-
|
|
69
|
-
the command, that is `latest`, which the 1.0 line rides — so the canonical
|
|
70
|
-
spelling names no tag, and npm runs this package's generator. The version a
|
|
71
|
-
versionless install resolves is registry truth: read it from the live registry
|
|
72
|
-
(`npm view @openelement/create dist-tags`), and from the framework's tracked
|
|
73
|
-
release-state manifest, which records the version each dist-tag was last
|
|
74
|
-
verified to serve. The 1.0 line is a new baseline — not a 0.x upgrade, with no
|
|
75
|
-
migration path from 0.x. Pin an exact version when reproducibility matters:
|
|
76
|
-
|
|
77
|
-
```bash
|
|
78
|
-
npm create @openelement@1.0.0-alpha.14 my-app
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
The generated starter depends on `@openelement/*` through caret ranges over
|
|
82
|
-
the release it was generated from, so a dependency update picks up later `1.0.0`
|
|
83
|
-
prereleases without a manifest edit.
|
|
69
|
+
`npm create @openelement` resolves the npm `latest` tag. The starter writes
|
|
70
|
+
caret ranges for the OpenElement packages based on the scaffold's release.
|
|
84
71
|
|
|
85
72
|
The canonical install command is exported from `@openelement/create/install-command` (one builder, every documented copy derives from it).
|
|
86
73
|
|
|
@@ -98,18 +85,10 @@ npx @openelement/create my-app
|
|
|
98
85
|
pnpm dlx --package=@openelement/create openelement-create my-app
|
|
99
86
|
```
|
|
100
87
|
|
|
101
|
-
The scaffolded project
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
The stable 0.43 line is still published, but it is not the 1.0 install path.
|
|
107
|
-
A versionless install resolves the npm `latest` dist-tag to the 1.0 line; pin
|
|
108
|
-
the maintenance line explicitly instead:
|
|
109
|
-
|
|
110
|
-
```bash
|
|
111
|
-
npm create @openelement@0.43 my-app
|
|
112
|
-
```
|
|
88
|
+
The scaffolded project runs on Node.js 24.2+ under npm, pnpm, yarn, or bun.
|
|
89
|
+
Keep using the package manager that installed its dependencies. For a checkout
|
|
90
|
+
whose source version is ahead of npm, the [source preview](../../README.md#preview-the-source-checkout)
|
|
91
|
+
builds the starter against the checkout’s packages.
|
|
113
92
|
|
|
114
93
|
## Requirements
|
|
115
94
|
|
|
@@ -150,12 +129,13 @@ npm create @openelement@0.43 my-app
|
|
|
150
129
|
`Response.json`
|
|
151
130
|
- `app/islands/` — the two islands (`my-counter` hydrating on idle,
|
|
152
131
|
`live-timer` client-only), the only code that ships JavaScript
|
|
153
|
-
- `app/components/` —
|
|
154
|
-
(
|
|
155
|
-
|
|
132
|
+
- `app/components/` — where page-scope components live when you add one
|
|
133
|
+
(the shipped pages are server functions in `app/routes/`; each SHADOW
|
|
134
|
+
element that needs one carries its own root `.css` sheet)
|
|
156
135
|
- `app/styles/theme.css` — the @theme role sheet, Tailwind-ON single-default
|
|
157
136
|
scaffold form (dark values ride
|
|
158
137
|
`prefers-color-scheme`)
|
|
138
|
+
- `tests/` - Node tests, including one for the `/api/ping` response
|
|
159
139
|
- `public/` - static assets
|
|
160
140
|
- `README.md` and `.gitignore` - starter docs and ignore rules
|
|
161
141
|
- `.node-version` - the Node development pin (`24.18.0`; the supported floor
|
package/package.json
CHANGED
package/src/template-builder.js
CHANGED
|
@@ -98,17 +98,11 @@ const TEMPLATE_FILES = [
|
|
|
98
98
|
["openelement.config.ts.tmpl", "openelement.config.ts"],
|
|
99
99
|
["app/styles/theme.css", "app/styles/theme.css"],
|
|
100
100
|
["app/head.tsx.tmpl", "app/head.tsx"],
|
|
101
|
-
["app/components/page-home.css", "app/components/page-home.css"],
|
|
102
|
-
["app/components/page-about.css", "app/components/page-about.css"],
|
|
103
|
-
["app/components/page-404.css", "app/components/page-404.css"],
|
|
104
|
-
["app/components/site-chrome.css", "app/components/site-chrome.css"],
|
|
105
|
-
["app/components/page-home.tsx.tmpl", "app/components/page-home.tsx"],
|
|
106
|
-
["app/components/page-about.tsx.tmpl", "app/components/page-about.tsx"],
|
|
107
|
-
["app/components/page-404.tsx.tmpl", "app/components/page-404.tsx"],
|
|
108
101
|
["app/routes/index.tsx.tmpl", "app/routes/index.tsx"],
|
|
109
102
|
["app/routes/about.tsx.tmpl", "app/routes/about.tsx"],
|
|
110
103
|
["app/routes/404.tsx.tmpl", "app/routes/404.tsx"],
|
|
111
104
|
["app/routes/api/ping.ts.tmpl", "app/routes/api/ping.ts"],
|
|
105
|
+
["tests/ping.test.ts.tmpl", "tests/ping.test.ts"],
|
|
112
106
|
["app/islands/my-counter.tsx.tmpl", "app/islands/my-counter.tsx"],
|
|
113
107
|
["app/islands/my-counter.css", "app/islands/my-counter.css"],
|
|
114
108
|
["app/islands/live-timer.tsx.tmpl", "app/islands/live-timer.tsx"],
|
package/src/version.js
CHANGED
package/templates/AGENTS.md.tmpl
CHANGED
|
@@ -14,11 +14,11 @@ working in this project.
|
|
|
14
14
|
|
|
15
15
|
```sh
|
|
16
16
|
npm run dev # dev server with HMR
|
|
17
|
-
npm run build # production build
|
|
17
|
+
npm run build # production build and dist-public/ upload directory
|
|
18
18
|
npm run start # serve the built output (and request-time routes)
|
|
19
19
|
npm run typecheck # tsc --noEmit
|
|
20
20
|
npm run lint # oxlint
|
|
21
|
-
npm run test #
|
|
21
|
+
npm run test # Node tests for the request-time API
|
|
22
22
|
npm run fmt # oxfmt
|
|
23
23
|
```
|
|
24
24
|
|
|
@@ -26,19 +26,21 @@ npm run fmt # oxfmt
|
|
|
26
26
|
|
|
27
27
|
- `app/routes/` — pages (default export) and form actions.
|
|
28
28
|
- `app/islands/` — interactive islands; each one hydrates with its declared strategy.
|
|
29
|
-
- `app/components/` —
|
|
29
|
+
- `app/components/` — where page-scope components live when you add one
|
|
30
|
+
(the shipped pages are server functions in `app/routes/`).
|
|
30
31
|
- `app/layout.tsx` — the shared document chrome every page renders inside.
|
|
31
32
|
- `app/head.tsx` — document head entries a config URL list cannot express.
|
|
32
33
|
- `openelement.config.ts` — framework options (head, i18n, middleware, ...).
|
|
33
|
-
- `public/` —
|
|
34
|
+
- `public/` — authored files for the public deployment.
|
|
35
|
+
- `tests/` — application tests run by Node’s built-in test runner.
|
|
34
36
|
|
|
35
37
|
## Rules
|
|
36
38
|
|
|
37
|
-
-
|
|
39
|
+
- Treat `dist/` and `dist-public/` as generated build output.
|
|
38
40
|
- Islands run in the browser. Importing `node:*` from an island fails the build
|
|
39
41
|
by design — server-only code belongs in route loaders and actions.
|
|
40
42
|
- A page that mounts no island ships no island JavaScript; keep static surfaces
|
|
41
43
|
static instead of widening the island graph.
|
|
42
|
-
- `dist/server/`
|
|
44
|
+
- Run `npx oe publish --check` before uploading `dist-public/`. Keep `dist/server/` and `dist/publish-manifest.json` in the application environment.
|
|
43
45
|
- Keep `npm run typecheck`, `npm run lint`, `npm run test` and `npm run build`
|
|
44
46
|
green after a change; `npm run check` is not a script in this scaffold.
|
package/templates/README.tmpl
CHANGED
|
@@ -1,198 +1,48 @@
|
|
|
1
|
-
# openElement
|
|
1
|
+
# openElement starter
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
scaffold it elsewhere with `npm create @openelement <project-name>` —
|
|
5
|
-
a static-first openElement app that shows its own costs. The landing page
|
|
6
|
-
carries two islands (`my-counter`, an interactive counter, and `live-timer`,
|
|
7
|
-
a client-only elapsed-time readout); every other page, including `/about`,
|
|
8
|
-
is prerendered HTML and CSS with no islands of its own — no island chunk is
|
|
9
|
-
executed there (a linked page's chunks can still be prefetched); the only
|
|
10
|
-
script such a page executes is the app-wide claim bootstrap (about 2 KB
|
|
11
|
-
gzipped) that runs while the app has any island. The badge on each section
|
|
12
|
-
names what it costs the client.
|
|
3
|
+
Start the dev server and open the URL it prints.
|
|
13
4
|
|
|
14
|
-
|
|
5
|
+
```sh
|
|
6
|
+
npm run dev
|
|
7
|
+
```
|
|
15
8
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
is verified on, pinned by the scaffold's own `.node-version`. The generated
|
|
20
|
-
project pins no package manager: every script is a plain command, so whichever
|
|
21
|
-
manager you install with runs them all.
|
|
9
|
+
Edit the heading in `app/routes/index.tsx` and save. The dev server updates the
|
|
10
|
+
home page. Then try the counter in `app/islands/my-counter.tsx` or add a route
|
|
11
|
+
under `app/routes/`.
|
|
22
12
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
13
|
+
Use Node.js 24.2 or newer. The scaffold pins the recommended development
|
|
14
|
+
version in `.node-version`. If you skipped installation, run the install
|
|
15
|
+
command printed by the CLI first. Use the same package manager for installs
|
|
16
|
+
and scripts.
|
|
27
17
|
|
|
28
|
-
|
|
29
|
-
ranges over the `1.0.0` prerelease this starter was generated from, so a
|
|
30
|
-
dependency update picks up later `1.0.0` prereleases (and the final `1.0.0`)
|
|
31
|
-
without editing this file.
|
|
18
|
+
## Find the examples
|
|
32
19
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
`
|
|
36
|
-
|
|
20
|
+
| Path | What it does |
|
|
21
|
+
| ---------------------------- | -------------------------------------------------------------- |
|
|
22
|
+
| `app/routes/index.tsx` | Prerenders `/` and hosts the counter and timer. |
|
|
23
|
+
| `app/islands/my-counter.tsx` | Renders the counter on the server and hydrates on idle. |
|
|
24
|
+
| `app/islands/live-timer.tsx` | Mounts the timer in the browser with `ssr: false`. |
|
|
25
|
+
| `app/routes/about.tsx` | Prerenders `/about` without islands of its own. |
|
|
26
|
+
| `app/routes/api/ping.ts` | Serves JSON from the request-time route `/api/ping`. |
|
|
27
|
+
| `app/routes/404.tsx` | Renders the fallback page for unmatched paths. |
|
|
28
|
+
| `app/layout.tsx` | Wraps every page in the shared header, main region and footer. |
|
|
29
|
+
| `app/styles/theme.css` | Defines the palette and Tailwind theme tokens. |
|
|
30
|
+
| `app/head.tsx` | Adds shared metadata and links to the document head. |
|
|
37
31
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
| Surface | Ships JavaScript? | Why |
|
|
41
|
-
| ------------------------------------ | --------------------- | ------------------------------------------------- |
|
|
42
|
-
| `/` hero + architecture sections | no | prerendered markup, styled with CSS |
|
|
43
|
-
| `/` counter island (`my-counter`) | yes, hydrates on idle | the one interactive piece |
|
|
44
|
-
| `/` live timer island (`live-timer`) | yes, client-only | a live clock has nothing to prerender |
|
|
45
|
-
| `/about` | no islands of its own | fully static SSG output, no island chunk executes |
|
|
46
|
-
| `/api/ping` | no (server) | a plain `Request → Response` handler |
|
|
47
|
-
| `/404` (unmatched paths) | no (server) | dynamic 404 from the styled 404 page |
|
|
48
|
-
|
|
49
|
-
The badge on each section is a Tailwind utility string on the span itself
|
|
50
|
-
(`bg-ok/8 text-ok` for a static section, `bg-brand-soft text-brand` for an
|
|
51
|
-
interactive one) — copy the span onto new sections and keep the map honest.
|
|
52
|
-
|
|
53
|
-
> Cost honesty: the island client is emitted app-wide today, so a page
|
|
54
|
-
> without islands (like `/about`) still carries the ~2 KB gzipped app-wide
|
|
55
|
-
> claim bootstrap — but no island chunk executes and no element-runtime
|
|
56
|
-
> preload is added for it: the build records islands per page and the client
|
|
57
|
-
> only activates tags the page hosts. Fetches can still be broader than
|
|
58
|
-
> execution when the reader follows a link, because the target page's chunks
|
|
59
|
-
> may be prefetched; what a page executes is always limited to its own
|
|
60
|
-
> registered islands.
|
|
61
|
-
|
|
62
|
-
## Where things live
|
|
63
|
-
|
|
64
|
-
Framework options have exactly one home: `openelement.config.ts`. It is
|
|
65
|
-
optional and nearly empty — every option it omits comes from a file
|
|
66
|
-
convention:
|
|
67
|
-
|
|
68
|
-
| Option | Convention |
|
|
69
|
-
| --------------------- | ------------------------------------------------------------------- |
|
|
70
|
-
| design tokens | `app/styles/theme.css` (the @theme role sheet) |
|
|
71
|
-
| layout | `app/layout.tsx` (the shared site chrome every page renders inside) |
|
|
72
|
-
| document head content | `app/head.tsx` (meta tags, preloads, inline CSS) |
|
|
73
|
-
| site title | the `name` field of `package.json` |
|
|
74
|
-
|
|
75
|
-
Passing framework options inline to `openElement()` while the config file
|
|
76
|
-
carries options is a hard error, and an unknown key fails the build with the
|
|
77
|
-
accepted-key list. `vite.config.ts` stays Vite-only: `plugins: [...openElement()]`.
|
|
78
|
-
|
|
79
|
-
- `app/routes/` — page routes, one file per URL. The default renderIntent is
|
|
80
|
-
`static`: prerendered at build time (SSG). `/about` and `/` are static.
|
|
81
|
-
- `app/routes/api/` — request-time server routes. `/api/ping` is a plain
|
|
82
|
-
WinterCG-shaped handler returning `Response.json`.
|
|
83
|
-
- `app/components/` — compiled page elements. Presentation is authored as
|
|
84
|
-
Tailwind utility classes in the markup; each element's `.css` sheet carries
|
|
85
|
-
only its root's box rule, which has no markup to carry it.
|
|
86
|
-
- `app/islands/` — client islands, the only code that ships JavaScript. Each
|
|
87
|
-
island declares its hydration strategy (`idle`, `load`, `visible`,
|
|
88
|
-
client-only) through `defineIslandConfig`.
|
|
89
|
-
- `app/layout.tsx` — the auto-registered layout, not an island itself: the
|
|
90
|
-
site chrome every page renders inside. The header, the `main` content
|
|
91
|
-
block, and the footer live here exactly once instead of being copied onto
|
|
92
|
-
each page. The build registers the layout automatically and projects each
|
|
93
|
-
page's render into its default slot, so a page module carries only its own
|
|
94
|
-
content. The layout is a convention: delete the file and pages still render
|
|
95
|
-
(carrying their own chrome again), or opt out explicitly with `layout: false`
|
|
96
|
-
in `openelement.config.ts`.
|
|
97
|
-
- `app/styles/theme.css` — the @theme role sheet: Tailwind-ON roles, the
|
|
98
|
-
starter palette (`bg-paper`, `text-brand`, `border-line`, …), dark and
|
|
99
|
-
forced-colors pairs, and the document base (`body`, `::selection`). Dev
|
|
100
|
-
serves the compiled result at `/.openElement/tailwind.css` and the build
|
|
101
|
-
emits it as the content-hashed document stylesheet the head links — both
|
|
102
|
-
through the official `@tailwindcss/vite` pipeline.
|
|
103
|
-
Dark values ride `prefers-color-scheme`; no theme runtime.
|
|
104
|
-
- `app/head.tsx` — structural head content the URL list cannot express.
|
|
32
|
+
A page with no islands of its own can still load the app-wide claim bootstrap
|
|
33
|
+
when other pages in the app use islands.
|
|
105
34
|
|
|
106
35
|
## Scripts
|
|
107
36
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
- `npm
|
|
113
|
-
- `npm run fmt` — format the sources (`oxfmt`).
|
|
114
|
-
- `npm run lint` — lint the sources (`oxlint`).
|
|
115
|
-
- `npm run typecheck` — type-check every route/component file (`tsc --noEmit`).
|
|
116
|
-
The check covers the whole `app/` directory (`tsconfig.json`), so new files
|
|
117
|
-
are picked up automatically.
|
|
118
|
-
- `npm test` — run Node's built-in test runner (the starter ships none).
|
|
119
|
-
- `npm run build` — production build into `dist/`: prerendered HTML for every
|
|
120
|
-
static route, plus the request-time server when the app has one.
|
|
121
|
-
- `npm start` — serve the production build.
|
|
122
|
-
|
|
123
|
-
`dev`, `build`, and `start` run the router CLI's short `oe` bin from the
|
|
124
|
-
`@openelement/router` dependency (`oe dev` / `oe build` / `oe start`; the same
|
|
125
|
-
entry is installed as `openelement`, so both spellings work). `oe dev` boots the
|
|
126
|
-
framework's own dev server — the SSR dev middleware, HMR, and the Tailwind
|
|
127
|
-
pipeline — with no extra wrapper, and `oe start --mode=preview` is the
|
|
128
|
-
static-only serve mode that refuses a build carrying a request-time server.
|
|
129
|
-
|
|
130
|
-
`oxfmt` and `oxlint` run with their defaults: both skip markdown, JSON, YAML,
|
|
131
|
-
and CSS, so `npx oxfmt --check` and `npx oxlint` pass on a fresh scaffold.
|
|
132
|
-
|
|
133
|
-
The Vite tree is one direct devDependency pin (`"vite": "8.0.16"` — the same
|
|
134
|
-
version `@openelement/router` resolves against), so every peer that asks for
|
|
135
|
-
Vite gets that copy. There is no workspace catalog and no `vite@*` override:
|
|
136
|
-
a pin plus the router's own aligned dependency is what keeps the tree single.
|
|
137
|
-
|
|
138
|
-
### Package manager
|
|
139
|
-
|
|
140
|
-
Install with whichever manager you prefer; the first install decides the
|
|
141
|
-
lockfile and everything afterwards follows it. The manifest deliberately
|
|
142
|
-
carries no `packageManager` field: with the field absent, the manager you run
|
|
143
|
-
first is the one that owns the project. The commands in this file are spelled
|
|
144
|
-
`npm run …` only because npm's spelling works unchanged under all four.
|
|
145
|
-
|
|
146
|
-
## Styling ownership
|
|
147
|
-
|
|
148
|
-
Styling is utility-first: presentation is authored as Tailwind utility
|
|
149
|
-
classes directly in the markup, and nothing else in the app spells it out.
|
|
150
|
-
The compiler admits those static tokens and the build generates the CSS — the
|
|
151
|
-
document stylesheet for light-root pages and the layout, one shared component
|
|
152
|
-
stylesheet for the shadow-root islands — so every page is fully styled with
|
|
153
|
-
zero client JavaScript and no CSS text ships inside JavaScript.
|
|
154
|
-
|
|
155
|
-
Two things stay CSS, and each has a reason:
|
|
156
|
-
|
|
157
|
-
- `app/styles/theme.css` — the design tokens and the document base (`body`,
|
|
158
|
-
`::selection`, the dark and forced-colors pairs). The document shell's
|
|
159
|
-
`body` is not authored markup, so no class can carry it.
|
|
160
|
-
- the per-element `.css` sheet — one `:host` rule for the element's own box.
|
|
161
|
-
A custom element is `display: inline` by default and the host tag is not
|
|
162
|
-
authored markup either.
|
|
163
|
-
|
|
164
|
-
The `.css` + `static styles` authoring path stays fully available — array any
|
|
165
|
-
sheet you want and the server inlines it into the SSR output as a
|
|
166
|
-
`@scope(<tag>)` block — the starter simply has no need for it.
|
|
167
|
-
|
|
168
|
-
## Brand assets
|
|
169
|
-
|
|
170
|
-
`public/openelement-mark.svg` is the openElement brand mark shipped with the
|
|
171
|
-
starter — the config file references it as the favicon, or delete it if
|
|
172
|
-
unused.
|
|
173
|
-
|
|
174
|
-
## Dependency notes
|
|
175
|
-
|
|
176
|
-
`@openelement/element` and `@openelement/router` are the runtime dependencies
|
|
177
|
-
your app imports. Everything else this manifest declares rides devDependencies:
|
|
178
|
-
`vite` (the tree the router's `oe dev` / `oe build` drive), `oxfmt` and `oxlint`
|
|
179
|
-
(the `fmt` / `lint` scripts), the Tailwind-ON build-time pins, the dev-server
|
|
180
|
-
pair — `@hono/vite-dev-server` (loaded lazily by the dev server) and its `hono`
|
|
181
|
-
peer — and the `typescript` pin.
|
|
37
|
+
- `npm test` checks the ping route with the Node.js test runner.
|
|
38
|
+
- `npm run typecheck` type-checks application code, tests and configuration.
|
|
39
|
+
- `npm run fmt` formats the source. `npm run lint` checks it.
|
|
40
|
+
- `npm run build` writes the public upload directory `dist-public/` and the request-time server in `dist/server/`. Run `npx oe publish --check` before uploading public files.
|
|
41
|
+
- `npm start` serves the production build.
|
|
182
42
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
dependencies (the compiler, the protocol package, TypeScript, PostCSS, `mime`,
|
|
187
|
-
`pathe`) and npm installs those in a production install too. Vite, Element,
|
|
188
|
-
`hono`, `marked` and `@hono/vite-dev-server` are optional peers of the router
|
|
189
|
-
and are never auto-installed, so a `--omit=dev` tree has no Vite: run the build
|
|
190
|
-
from the full install and ship only its output.
|
|
43
|
+
Framework options live in `openelement.config.ts`. Vite configuration lives in
|
|
44
|
+
`vite.config.ts`. The router writes its working files to `.openElement/` and
|
|
45
|
+
recreates the directory as needed.
|
|
191
46
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
`@openelement/router`: `@openelement/router/hono` (`createHonoAdapter`) is the
|
|
195
|
-
one opt-in if you ever want to mount the built handler inside your own Hono
|
|
196
|
-
app. For Nitro deployments, the built handler bridges through the
|
|
197
|
-
`@openelement/router/nitro-mount` subpath of the one `@openelement/router`
|
|
198
|
-
dependency. Do not remove them.
|
|
47
|
+
To create another project, use `npm create @openelement <project-name>`.
|
|
48
|
+
[Documentation](https://openelement.org)
|
|
@@ -1,64 +1,60 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* live-timer — client-only live stats island (compiled).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* Generated-element lane (2026-11-20): the class this template used to declare
|
|
5
|
+
* is a function component with a sidecar. `hydrate: 'only'` with `ssr: false`
|
|
6
|
+
* renders nothing on the server; the client entry builds the shadow root from
|
|
7
|
+
* the compiled Part Program and starts the clock in `onConnect`, measured from
|
|
8
|
+
* the document's time origin. The cleanup `onConnect` returns stops the
|
|
9
|
+
* interval when the host leaves the tree, so a reconnect arms exactly one clock.
|
|
10
|
+
*
|
|
11
|
+
* Styling has ONE owner: the sidecar's `styles` declaration. This island is
|
|
12
|
+
* client-only, so no DSD template exists to carry a `<link>`: the compiler
|
|
13
|
+
* turns the declaration into a real `import` of the same sheet and the shell
|
|
14
|
+
* adopts it into the root it creates. The `:host` box rule in
|
|
15
|
+
* `app/islands/live-timer.css` therefore reaches the host, and the single
|
|
16
|
+
* declaration still feeds the build-time asset and the DSD link for the
|
|
17
|
+
* islands that do render on the server.
|
|
8
18
|
*/
|
|
9
19
|
import { defineIslandConfig } from "@openelement/router";
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
export const openElement = defineIslandConfig({ hydrate: "only", ssr: false, dsd: false });
|
|
14
|
-
|
|
15
|
-
// The interval handle rides compiled per-instance property state (module-level
|
|
16
|
-
// runtime statements are outside the compiled grammar, OEC9008).
|
|
17
|
-
@element("live-timer", { root: "shadow-open" })
|
|
18
|
-
export default class LiveTimer extends OpenElement {
|
|
19
|
-
static override styles = [timerStyles];
|
|
20
|
+
import { signal } from "@openelement/element";
|
|
21
|
+
import { onConnect } from "@openelement/element/lifecycle";
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
export const openElement = defineIslandConfig({
|
|
24
|
+
hydrate: "only",
|
|
25
|
+
ssr: false,
|
|
26
|
+
dsd: false,
|
|
27
|
+
root: "shadow",
|
|
28
|
+
styles: ["./live-timer.css"],
|
|
29
|
+
});
|
|
25
30
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
*
|
|
29
|
-
|
|
30
|
-
* both DOM and node types (@types/node), so the bare `setInterval` name
|
|
31
|
-
* resolves to Node's overload and the handle becomes a `NodeJS.Timeout`
|
|
32
|
-
* (TS2322 on the assignment). The browser entry runs in the DOM, where the
|
|
33
|
-
* call returns a `number` — the honest type for this field.
|
|
34
|
-
*/
|
|
35
|
-
@property({ reflect: false, attribute: false })
|
|
36
|
-
interval = 0;
|
|
31
|
+
function LiveTimer() {
|
|
32
|
+
/** Elapsed seconds, preformatted: a compiled text Part binds a plain signal
|
|
33
|
+
* value, never a method call (OEC9013). */
|
|
34
|
+
const elapsed = signal("0.0");
|
|
37
35
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
onConnect(() => {
|
|
37
|
+
// `globalThis.setInterval`, not the bare global: the generated tsconfig
|
|
38
|
+
// loads both DOM and node types, so the bare name resolves to Node's
|
|
39
|
+
// overload. No handle is stored on the element; the returned cleanup owns
|
|
40
|
+
// it for the connection's lifetime (the emitted factory keeps the closure).
|
|
41
|
+
const interval = globalThis.setInterval(() => {
|
|
42
|
+
elapsed.value = (Math.round(globalThis.performance.now()) / 1000).toFixed(1);
|
|
42
43
|
}, 100);
|
|
43
|
-
|
|
44
|
+
return () => globalThis.clearInterval(interval);
|
|
45
|
+
});
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
<
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
class="min-w-[6ch] text-right text-[1.4rem] font-semibold text-brand tabular-nums"
|
|
57
|
-
>
|
|
58
|
-
{this.elapsed}
|
|
59
|
-
</span>
|
|
60
|
-
<span class="text-[0.85rem] text-ink-soft">seconds on this page</span>
|
|
61
|
-
</div>
|
|
62
|
-
);
|
|
63
|
-
}
|
|
47
|
+
return (
|
|
48
|
+
<div class="inline-flex items-baseline gap-[0.6rem]">
|
|
49
|
+
<span
|
|
50
|
+
id="elapsed"
|
|
51
|
+
class="min-w-[6ch] text-right text-[1.4rem] font-semibold text-brand tabular-nums"
|
|
52
|
+
>
|
|
53
|
+
{elapsed.value}
|
|
54
|
+
</span>
|
|
55
|
+
<span class="text-[0.85rem] text-ink-soft">seconds on this page</span>
|
|
56
|
+
</div>
|
|
57
|
+
);
|
|
64
58
|
}
|
|
59
|
+
|
|
60
|
+
export default LiveTimer;
|
|
@@ -1,52 +1,52 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* my-counter — the interactive counter island (compiled).
|
|
3
3
|
*
|
|
4
|
-
* Hydrates on idle; the buttons drive compiled event Parts and the count
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Hydrates on idle; the buttons drive compiled event Parts and the count renders
|
|
5
|
+
* through a compiled text Part. Presentation is utility-first below, and the
|
|
6
|
+
* shadow root keeps the island a DSD citizen.
|
|
7
|
+
*
|
|
8
|
+
* Generated-element lane (2026-11-20): the class this template used to declare is
|
|
9
|
+
* a function component with a sidecar. `count` is the lane's `signal` intrinsic —
|
|
10
|
+
* a reactive node the compiler creates in the retained instance scope, so the
|
|
11
|
+
* buttons write it and the text Part reads it with no second state channel. The
|
|
12
|
+
* sidecar's `styles` channel is the DSD style-link carrier (M09-2e / #1803): the
|
|
13
|
+
* sheet is declared as a marked `<link>` INSIDE the shadow template.
|
|
7
14
|
*/
|
|
8
15
|
import { defineIslandConfig } from "@openelement/router";
|
|
9
|
-
import {
|
|
10
|
-
import counterStyles from "./my-counter.css";
|
|
11
|
-
|
|
12
|
-
export const openElement = defineIslandConfig({ hydrate: "idle", ssr: true, dsd: true });
|
|
13
|
-
|
|
14
|
-
@element("my-counter", { root: "shadow-open" })
|
|
15
|
-
export default class MyCounter extends OpenElement {
|
|
16
|
-
static override styles = [counterStyles];
|
|
16
|
+
import { signal } from "@openelement/element";
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
export const openElement = defineIslandConfig({
|
|
19
|
+
hydrate: "idle",
|
|
20
|
+
ssr: true,
|
|
21
|
+
dsd: true,
|
|
22
|
+
root: "shadow",
|
|
23
|
+
styles: ["./my-counter.css"],
|
|
24
|
+
});
|
|
20
25
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
26
|
+
function MyCounter() {
|
|
27
|
+
const count = signal(0);
|
|
24
28
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
>
|
|
47
|
-
+
|
|
48
|
-
</button>
|
|
49
|
-
</div>
|
|
50
|
-
);
|
|
51
|
-
}
|
|
29
|
+
return (
|
|
30
|
+
<div class="inline-flex items-center gap-3">
|
|
31
|
+
<button
|
|
32
|
+
class="size-8 cursor-pointer rounded-(--radius-s) border border-line bg-paper text-[1rem] leading-none text-ink transition-[border-color,color] duration-150 ease-out hover:border-brand hover:text-brand"
|
|
33
|
+
type="button"
|
|
34
|
+
onClick={() => count.value--}
|
|
35
|
+
>
|
|
36
|
+
-
|
|
37
|
+
</button>
|
|
38
|
+
<span id="count" class="min-w-[2ch] text-center font-semibold tabular-nums">
|
|
39
|
+
{count.value}
|
|
40
|
+
</span>
|
|
41
|
+
<button
|
|
42
|
+
class="size-8 cursor-pointer rounded-(--radius-s) border border-line bg-paper text-[1rem] leading-none text-ink transition-[border-color,color] duration-150 ease-out hover:border-brand hover:text-brand"
|
|
43
|
+
type="button"
|
|
44
|
+
onClick={() => count.value++}
|
|
45
|
+
>
|
|
46
|
+
+
|
|
47
|
+
</button>
|
|
48
|
+
</div>
|
|
49
|
+
);
|
|
52
50
|
}
|
|
51
|
+
|
|
52
|
+
export default MyCounter;
|