@openelement/create 1.0.0-alpha.12 → 1.0.0-alpha.14
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 +16 -13
- package/package.json +1 -1
- package/src/cli.js +10 -1
- package/src/template-builder.js +3 -1
- package/src/version.js +1 -1
- package/templates/README.tmpl +73 -33
- package/templates/app/components/badges.css +24 -5
- package/templates/app/components/page-404.css +21 -7
- package/templates/app/components/page-404.tsx.tmpl +16 -35
- package/templates/app/components/page-about.css +72 -15
- package/templates/app/components/page-about.tsx.tmpl +62 -78
- package/templates/app/components/page-home.css +135 -23
- package/templates/app/components/page-home.tsx.tmpl +87 -103
- package/templates/app/components/site-chrome.css +68 -15
- package/templates/app/head.tsx.tmpl +8 -4
- package/templates/app/islands/app-shell.tsx.tmpl +54 -0
- package/templates/app/islands/live-timer.css +21 -7
- package/templates/app/islands/live-timer.tsx.tmpl +9 -9
- package/templates/app/islands/my-counter.css +32 -11
- package/templates/app/islands/my-counter.tsx.tmpl +13 -9
- package/templates/app/routes/404.tsx.tmpl +10 -6
- package/templates/app/routes/about.tsx.tmpl +4 -4
- package/templates/app/routes/api/ping.ts.tmpl +2 -2
- package/templates/app/routes/index.tsx.tmpl +4 -4
- package/templates/app/styles/theme.css +2 -2
- package/templates/openelement.config.ts.tmpl +8 -8
- package/templates/package.json.tmpl +17 -17
- package/templates/pnpm-workspace.yaml.tmpl +29 -0
- package/templates/vite.config.ts.tmpl +12 -3
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* app/islands/app-shell.tsx — the auto-registered application shell.
|
|
3
|
+
*
|
|
4
|
+
* The convention path is enough: the build finds this module, registers its
|
|
5
|
+
* compiled class under the `app-shell` tag, and renders EVERY page inside
|
|
6
|
+
* it, projecting the page's own render into the default <slot>. The header
|
|
7
|
+
* and footer markup that used to be copied onto every page lives here
|
|
8
|
+
* exactly once — a page module now carries only its own content.
|
|
9
|
+
*
|
|
10
|
+
* The shadow root (root: 'shadow-open') is what makes the projection work:
|
|
11
|
+
* the chrome below renders in this element's shadow tree (styled by the
|
|
12
|
+
* site-chrome sheet in `static styles`), while the slotted page content
|
|
13
|
+
* stays in the page element's own light DOM with its own @scope styles.
|
|
14
|
+
* Layout tokens from app/styles/theme.css inherit through the boundary.
|
|
15
|
+
*
|
|
16
|
+
* The shell is a convention, not a requirement: delete this file and every
|
|
17
|
+
* page still renders (back to carrying its own chrome), or opt out
|
|
18
|
+
* explicitly with `appShell: false` in openelement.config.ts.
|
|
19
|
+
*/
|
|
20
|
+
import { element, OpenElement } from "@openelement/element";
|
|
21
|
+
import siteChromeStyles from "../components/site-chrome.css";
|
|
22
|
+
|
|
23
|
+
@element("app-shell", { root: "shadow-open" })
|
|
24
|
+
export default class AppShell extends OpenElement {
|
|
25
|
+
static override styles = [siteChromeStyles];
|
|
26
|
+
|
|
27
|
+
render() {
|
|
28
|
+
return (
|
|
29
|
+
<div class="page-body">
|
|
30
|
+
<header class="site-head">
|
|
31
|
+
<div class="bar">
|
|
32
|
+
<a class="site-brand" href="/">
|
|
33
|
+
openElement
|
|
34
|
+
</a>
|
|
35
|
+
<nav>
|
|
36
|
+
<a href="/">Home</a>
|
|
37
|
+
<a href="/about">About</a>
|
|
38
|
+
<a href="/api/ping">API</a>
|
|
39
|
+
</nav>
|
|
40
|
+
</div>
|
|
41
|
+
</header>
|
|
42
|
+
<main>
|
|
43
|
+
<slot></slot>
|
|
44
|
+
</main>
|
|
45
|
+
<footer class="site-foot">
|
|
46
|
+
<div class="bar">
|
|
47
|
+
<span>Generated by @openelement/create.</span>
|
|
48
|
+
<a href="https://openelement.org">openelement.org</a>
|
|
49
|
+
</div>
|
|
50
|
+
</footer>
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -1,9 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
:host {
|
|
2
|
+
display: inline-block;
|
|
3
|
+
}
|
|
4
|
+
.timer-row {
|
|
5
|
+
display: inline-flex;
|
|
6
|
+
gap: 0.6rem;
|
|
7
|
+
align-items: baseline;
|
|
8
|
+
}
|
|
9
|
+
/* #1582: the selector names the id the class renders (#elapsed) — a
|
|
5
10
|
`.value` selector matched nothing, so the clock lost its brand color
|
|
6
11
|
and tabular figures. */
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
#elapsed {
|
|
13
|
+
min-width: 6ch;
|
|
14
|
+
text-align: right;
|
|
15
|
+
font-variant-numeric: tabular-nums;
|
|
16
|
+
font-weight: 600;
|
|
17
|
+
font-size: 1.4rem;
|
|
18
|
+
color: var(--brand);
|
|
19
|
+
}
|
|
20
|
+
.unit {
|
|
21
|
+
color: var(--ink-soft);
|
|
22
|
+
font-size: 0.85rem;
|
|
23
|
+
}
|
|
@@ -7,24 +7,24 @@
|
|
|
7
7
|
* time origin (performance.now()), so the number is honest page time, and
|
|
8
8
|
* disconnectedCallback stops the interval when the host leaves the tree.
|
|
9
9
|
*/
|
|
10
|
-
import { defineIslandConfig } from
|
|
11
|
-
import { element, OpenElement, property } from
|
|
12
|
-
import timerStyles from
|
|
10
|
+
import { defineIslandConfig } from "@openelement/router";
|
|
11
|
+
import { element, OpenElement, property } from "@openelement/element";
|
|
12
|
+
import timerStyles from "./live-timer.css";
|
|
13
13
|
|
|
14
|
-
export const openElement = defineIslandConfig({ hydrate:
|
|
14
|
+
export const openElement = defineIslandConfig({ hydrate: "only", ssr: false, dsd: false });
|
|
15
15
|
|
|
16
16
|
// The interval handle rides the compiled per-instance property state: island
|
|
17
17
|
// classes carry compiled @property fields and methods, and module-level
|
|
18
18
|
// runtime statements are outside the compiled grammar (OEC9008). In the
|
|
19
19
|
// browser setInterval returns a number, so the handle is a plain number here.
|
|
20
|
-
@element(
|
|
20
|
+
@element("live-timer", { root: "shadow-open" })
|
|
21
21
|
export default class LiveTimer extends OpenElement {
|
|
22
22
|
static override styles = [timerStyles];
|
|
23
23
|
|
|
24
24
|
/** Elapsed seconds as preformatted text (compiled text Parts bind plain
|
|
25
25
|
* properties — no method calls in a text region, OEC9013). */
|
|
26
26
|
@property({ reflect: false, attribute: false })
|
|
27
|
-
elapsed =
|
|
27
|
+
elapsed = "0.0";
|
|
28
28
|
|
|
29
29
|
/** The ticking interval's handle; 0 when the host is not connected. */
|
|
30
30
|
@property({ reflect: false, attribute: false })
|
|
@@ -45,9 +45,9 @@ export default class LiveTimer extends OpenElement {
|
|
|
45
45
|
|
|
46
46
|
render() {
|
|
47
47
|
return (
|
|
48
|
-
<div class=
|
|
49
|
-
<span id=
|
|
50
|
-
<span class=
|
|
48
|
+
<div class="timer-row">
|
|
49
|
+
<span id="elapsed">{this.elapsed}</span>
|
|
50
|
+
<span class="unit">seconds on this page</span>
|
|
51
51
|
</div>
|
|
52
52
|
);
|
|
53
53
|
}
|
|
@@ -1,11 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
:host {
|
|
2
|
+
display: inline-block;
|
|
3
|
+
}
|
|
4
|
+
.counter-row {
|
|
5
|
+
display: inline-flex;
|
|
6
|
+
gap: 0.75rem;
|
|
7
|
+
align-items: center;
|
|
8
|
+
}
|
|
9
|
+
button {
|
|
10
|
+
width: 2rem;
|
|
11
|
+
height: 2rem;
|
|
12
|
+
border: 1px solid var(--line);
|
|
13
|
+
border-radius: var(--radius-s);
|
|
14
|
+
background: var(--paper);
|
|
15
|
+
color: var(--ink);
|
|
16
|
+
font-size: 1rem;
|
|
17
|
+
line-height: 1;
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
transition:
|
|
20
|
+
border-color 0.15s ease,
|
|
21
|
+
color 0.15s ease;
|
|
22
|
+
}
|
|
23
|
+
button:hover {
|
|
24
|
+
border-color: var(--brand);
|
|
25
|
+
color: var(--brand);
|
|
26
|
+
}
|
|
27
|
+
span {
|
|
28
|
+
min-width: 2ch;
|
|
29
|
+
text-align: center;
|
|
30
|
+
font-variant-numeric: tabular-nums;
|
|
31
|
+
font-weight: 600;
|
|
32
|
+
}
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
* shadow root keeps the island a DSD citizen. Design tokens from
|
|
7
7
|
* app/styles/theme.css inherit through the shadow boundary.
|
|
8
8
|
*/
|
|
9
|
-
import { defineIslandConfig } from
|
|
10
|
-
import { element, OpenElement, property } from
|
|
11
|
-
import counterStyles from
|
|
9
|
+
import { defineIslandConfig } from "@openelement/router";
|
|
10
|
+
import { element, OpenElement, property } from "@openelement/element";
|
|
11
|
+
import counterStyles from "./my-counter.css";
|
|
12
12
|
|
|
13
|
-
export const openElement = defineIslandConfig({ hydrate:
|
|
13
|
+
export const openElement = defineIslandConfig({ hydrate: "idle", ssr: true, dsd: true });
|
|
14
14
|
|
|
15
|
-
@element(
|
|
15
|
+
@element("my-counter", { root: "shadow-open" })
|
|
16
16
|
export default class MyCounter extends OpenElement {
|
|
17
17
|
static override styles = [counterStyles];
|
|
18
18
|
|
|
@@ -29,10 +29,14 @@ export default class MyCounter extends OpenElement {
|
|
|
29
29
|
|
|
30
30
|
render() {
|
|
31
31
|
return (
|
|
32
|
-
<div class=
|
|
33
|
-
<button type=
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
<div class="counter-row">
|
|
33
|
+
<button type="button" onClick={this.decrement}>
|
|
34
|
+
-
|
|
35
|
+
</button>
|
|
36
|
+
<span id="count">{this.count}</span>
|
|
37
|
+
<button type="button" onClick={this.increment}>
|
|
38
|
+
+
|
|
39
|
+
</button>
|
|
36
40
|
</div>
|
|
37
41
|
);
|
|
38
42
|
}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Styled 404 (#923):
|
|
3
|
-
*
|
|
2
|
+
* Styled 404 (#923). `renderIntent: { mode: 'dynamic' }` keeps this page on
|
|
3
|
+
* the request-time path, and it is the reason this starter's build emits
|
|
4
|
+
* `dist/server/`: the request-time server renders it with a 404 status for
|
|
5
|
+
* every unmatched path, so the build writes no static 404.html. Drop the
|
|
6
|
+
* renderIntent line and the route becomes prerenderable — a build with no
|
|
7
|
+
* other request-time route then writes the page to dist/404.html.
|
|
4
8
|
*/
|
|
5
|
-
import { definePage } from
|
|
6
|
-
import NotFoundPage from
|
|
9
|
+
import { definePage } from "@openelement/router";
|
|
10
|
+
import NotFoundPage from "../components/page-404.tsx";
|
|
7
11
|
|
|
8
12
|
export default definePage(NotFoundPage, {
|
|
9
|
-
renderIntent: { mode:
|
|
10
|
-
head: { title:
|
|
13
|
+
renderIntent: { mode: "dynamic" },
|
|
14
|
+
head: { title: "404 — openElement" },
|
|
11
15
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/** Static About page (default renderIntent mode 'static') — prerendered at build time. */
|
|
2
|
-
import { definePage } from
|
|
3
|
-
import AboutPage from
|
|
2
|
+
import { definePage } from "@openelement/router";
|
|
3
|
+
import AboutPage from "../components/page-about.tsx";
|
|
4
4
|
|
|
5
5
|
export default definePage(AboutPage, {
|
|
6
6
|
head: {
|
|
7
|
-
title:
|
|
8
|
-
description:
|
|
7
|
+
title: "About",
|
|
8
|
+
description: "Static-first openElement showcase — this page ships no islands",
|
|
9
9
|
},
|
|
10
10
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/** Static home page (default renderIntent mode 'static') — prerendered at build time. */
|
|
2
|
-
import { definePage } from
|
|
3
|
-
import HomePage from
|
|
2
|
+
import { definePage } from "@openelement/router";
|
|
3
|
+
import HomePage from "../components/page-home.tsx";
|
|
4
4
|
|
|
5
5
|
export default definePage(HomePage, {
|
|
6
6
|
head: {
|
|
7
|
-
title:
|
|
8
|
-
description:
|
|
7
|
+
title: "Rendered before JavaScript arrives",
|
|
8
|
+
description: "openElement showcase — static pages, alive where it counts",
|
|
9
9
|
},
|
|
10
10
|
});
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
|
|
54
54
|
/* Dark pairs (shadcn v4 convention; the selector matches the runtime theme
|
|
55
55
|
attribute the ui package documents). */
|
|
56
|
-
:root[data-theme=
|
|
57
|
-
:host([data-theme=
|
|
56
|
+
:root[data-theme="dark"],
|
|
57
|
+
:host([data-theme="dark"]) {
|
|
58
58
|
--color-background: var(--color-zinc-950);
|
|
59
59
|
--color-foreground: var(--color-zinc-50);
|
|
60
60
|
|
|
@@ -20,22 +20,22 @@
|
|
|
20
20
|
// Passing framework options inline to openElement() while this file carries
|
|
21
21
|
// options is a hard error: framework options cannot have two homes. Unknown
|
|
22
22
|
// keys are rejected with the accepted-key list.
|
|
23
|
-
import { defineConfig } from
|
|
23
|
+
import { defineConfig } from "@openelement/router";
|
|
24
24
|
|
|
25
25
|
export default defineConfig({
|
|
26
26
|
// The Tailwind preset — the single-default scaffold form. The roles in
|
|
27
27
|
// app/styles/theme.css compile into the preset's deliverable both ways: dev
|
|
28
28
|
// serves the compile from /.openElement/tailwind-preset/entry.css and links
|
|
29
29
|
// it in the document head, the build emits the same compile as the
|
|
30
|
-
// layer-ordered /assets/open-tailwind.css after the SSG render. The path
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
tailwind: { theme: [
|
|
30
|
+
// layer-ordered /assets/open-tailwind.css after the SSG render. The path is
|
|
31
|
+
// app-relative (resolved against the app root); package CSS specifiers such
|
|
32
|
+
// as '@openelement/ui/theme.css' also work here.
|
|
33
|
+
tailwind: { theme: ["app/styles/theme.css"] },
|
|
34
34
|
head: {
|
|
35
35
|
// Titles default to the package.json "name"; this overrides the document
|
|
36
36
|
// title fallback while page routes keep their own `head: { title }`.
|
|
37
|
-
title:
|
|
38
|
-
description:
|
|
39
|
-
favicon:
|
|
37
|
+
title: "openElement Showcase",
|
|
38
|
+
description: "A static-first openElement showcase — rendered before JavaScript arrives.",
|
|
39
|
+
favicon: "/openelement-mark.svg",
|
|
40
40
|
},
|
|
41
41
|
});
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "${name}",
|
|
3
|
-
"private": true,
|
|
4
3
|
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
|
-
"packageManager": "pnpm@12.8.1",
|
|
7
|
-
"engines": {
|
|
8
|
-
"node": ">=24.2"
|
|
9
|
-
},
|
|
10
6
|
"scripts": {
|
|
11
|
-
"dev": "
|
|
12
|
-
"
|
|
7
|
+
"dev": "vp dev",
|
|
8
|
+
"build": "oe build",
|
|
9
|
+
"start": "oe start",
|
|
13
10
|
"test": "node --test",
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
11
|
+
"fmt": "vp fmt",
|
|
12
|
+
"lint": "vp lint",
|
|
13
|
+
"typecheck": "tsc --noEmit"
|
|
17
14
|
},
|
|
18
15
|
"dependencies": {
|
|
19
|
-
"@
|
|
20
|
-
"@openelement/
|
|
21
|
-
"@openelement/router": "${v.router}",
|
|
22
|
-
"hono": "^4.12"
|
|
16
|
+
"@openelement/element": "^${v.element}",
|
|
17
|
+
"@openelement/router": "^${v.router}"
|
|
23
18
|
},
|
|
24
19
|
"devDependencies": {
|
|
25
|
-
"@
|
|
20
|
+
"@hono/vite-dev-server": "^0.25.3",
|
|
26
21
|
"@tailwindcss/vite": "4.3.3",
|
|
22
|
+
"hono": "^4.12",
|
|
27
23
|
"tailwindcss": "4.3.3",
|
|
28
24
|
"typescript": "6.0.3",
|
|
29
|
-
"vite": "
|
|
30
|
-
}
|
|
25
|
+
"vite-plus": "catalog:"
|
|
26
|
+
},
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=24.2"
|
|
29
|
+
},
|
|
30
|
+
"packageManager": "pnpm@12.8.1"
|
|
31
31
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# pnpm workspace bookkeeping for this project. pnpm rewrites this file (for
|
|
2
|
+
# example when it records a new minimumReleaseAgeExclude entry you approve);
|
|
3
|
+
# keep it and review the entries it lists.
|
|
4
|
+
#
|
|
5
|
+
# catalog: the Vite+ form. `vite` resolves to the Vite+ core build through
|
|
6
|
+
# the catalog and the `vite@*` override below, so every peer that asks for
|
|
7
|
+
# vite (the router's dev server, the Tailwind Vite plugin) gets the same
|
|
8
|
+
# Vite+ tree; `vp dev` serves through it directly.
|
|
9
|
+
#
|
|
10
|
+
# minimumReleaseAgeExclude: pnpm's supply-chain cooldown withholds versions
|
|
11
|
+
# published inside its maturity window. These entries are exempt: the
|
|
12
|
+
# @openelement packages at the version this project was generated from (a
|
|
13
|
+
# fresh scaffold installs on release day) and vite-plus itself.
|
|
14
|
+
catalog:
|
|
15
|
+
vite: npm:@voidzero-dev/vite-plus-core@1.1.0
|
|
16
|
+
vite-plus: 1.1.0
|
|
17
|
+
minimumReleaseAgeExclude:
|
|
18
|
+
- "@openelement/compiler@${v.element}"
|
|
19
|
+
- "@openelement/element@${v.element}"
|
|
20
|
+
- "@openelement/protocol@${v.element}"
|
|
21
|
+
- "@openelement/router@${v.router}"
|
|
22
|
+
- "vite-plus@1.1.0"
|
|
23
|
+
overrides:
|
|
24
|
+
vite@*: "catalog:"
|
|
25
|
+
peerDependencyRules:
|
|
26
|
+
allowAny:
|
|
27
|
+
- vite
|
|
28
|
+
allowedVersions:
|
|
29
|
+
vite: "*"
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
import { openElement } from
|
|
2
|
-
import { defineConfig } from
|
|
1
|
+
import { openElement } from "@openelement/router/vite";
|
|
2
|
+
import { defineConfig } from "vite-plus";
|
|
3
3
|
|
|
4
4
|
// Vite configuration only. Framework options live in openelement.config.ts —
|
|
5
5
|
// the plugin reads that file itself, so the plugin call stays bare. The JSX
|
|
6
6
|
// transform is owned by the plugin's compiler pass (TSX → Part Program);
|
|
7
7
|
// nothing JSX-related needs configuring here.
|
|
8
|
+
//
|
|
9
|
+
// `defineConfig` comes from vite-plus so the config carries the Vite+ native
|
|
10
|
+
// tool blocks: `fmt` is what `vp fmt` reads. Its ignore list stays empty —
|
|
11
|
+
// the formatter's defaults already skip markdown, JSON, YAML, and CSS, so
|
|
12
|
+
// the authored sources ship in formatted form and `pnpm fmt --check`
|
|
13
|
+
// (`vp fmt --check`) passes out of the box.
|
|
8
14
|
export default defineConfig({
|
|
9
|
-
|
|
15
|
+
fmt: {
|
|
16
|
+
ignorePatterns: [],
|
|
17
|
+
},
|
|
18
|
+
base: "/",
|
|
10
19
|
plugins: [...openElement()],
|
|
11
20
|
});
|