@openelement/create 1.0.0-alpha.1 → 1.0.0-alpha.11
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 +99 -28
- package/package.json +15 -4
- package/src/cli.d.ts +1 -1
- package/src/cli.js +254 -65
- package/src/install-command.d.ts +50 -0
- package/src/install-command.js +52 -0
- package/src/pm.js +30 -0
- package/src/template-builder.js +78 -174
- package/src/version.js +12 -6
- package/templates/README.tmpl +110 -47
- package/templates/app/components/badges.css +5 -0
- package/templates/app/components/page-404.css +7 -0
- package/templates/app/components/page-404.tsx.tmpl +32 -11
- package/templates/app/components/page-about.css +15 -0
- package/templates/app/components/page-about.tsx.tmpl +93 -0
- package/templates/app/components/page-home.css +23 -0
- package/templates/app/components/page-home.tsx.tmpl +114 -40
- package/templates/app/components/site-chrome.css +15 -0
- package/templates/app/head.tsx.tmpl +32 -0
- package/templates/app/islands/live-timer.css +6 -0
- package/templates/app/islands/live-timer.tsx.tmpl +54 -0
- package/templates/app/islands/my-counter.css +11 -0
- package/templates/app/islands/my-counter.tsx.tmpl +5 -4
- package/templates/app/routes/about.tsx.tmpl +10 -0
- package/templates/app/routes/api/ping.ts.tmpl +12 -0
- package/templates/app/routes/index.tsx.tmpl +2 -2
- package/templates/app/styles/recipes.css +43 -0
- package/templates/app/styles/theme.css +170 -0
- package/templates/gitignore.tmpl +1 -0
- package/templates/openelement.config.ts.tmpl +39 -0
- package/templates/package.json.tmpl +26 -1
- package/templates/tsconfig.json.tmpl +16 -0
- package/templates/vite.config.ts.tmpl +6 -32
- package/templates/app/components/page-blog-index.tsx.tmpl +0 -39
- package/templates/app/components/page-blog-welcome.tsx.tmpl +0 -57
- package/templates/app/components/page-contact.tsx.tmpl +0 -49
- package/templates/app/components/page-freshness.tsx.tmpl +0 -26
- package/templates/app/components/page-styles.ts.tmpl +0 -166
- package/templates/app/islands/app-shell.tsx.tmpl +0 -58
- package/templates/app/islands/only-ticker.tsx.tmpl +0 -34
- package/templates/app/routes/api/health.ts.tmpl +0 -7
- package/templates/app/routes/blog/index.tsx.tmpl +0 -10
- package/templates/app/routes/blog/welcome.tsx.tmpl +0 -7
- package/templates/app/routes/contact.tsx.tmpl +0 -36
- package/templates/app/routes/freshness.tsx.tmpl +0 -17
- package/templates/deno.json.tmpl +0 -25
package/src/pm.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
//#region src/pm.ts
|
|
4
|
+
/**
|
|
5
|
+
* Package-manager detection for the create CLI's install/start steps.
|
|
6
|
+
*
|
|
7
|
+
* A separate module (not cli.ts): the module is imported by the tests, and
|
|
8
|
+
* cli.ts executes the CLI at import time (top-level main), so anything the
|
|
9
|
+
* tests need to call must live beside it, not inside it.
|
|
10
|
+
*/
|
|
11
|
+
/** One package-manager probe: spawn `<pm> --version` off-PATH failures give ENOENT. */
|
|
12
|
+
function packageManagerAvailable(pm) {
|
|
13
|
+
const probe = spawnSync(pm, ["--version"], {
|
|
14
|
+
stdio: "ignore",
|
|
15
|
+
shell: process.platform === "win32"
|
|
16
|
+
});
|
|
17
|
+
return probe.error === void 0 && probe.status === 0;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Package-manager detection (pnpm wins, npm is the floor). Both ship with
|
|
21
|
+
* Node-adjacent toolchains; the first probe that answers --version wins.
|
|
22
|
+
* Never returns: with no manager the CLI fails with the manual-install path.
|
|
23
|
+
*/
|
|
24
|
+
function detectPackageManager() {
|
|
25
|
+
for (const pm of ["pnpm", "npm"]) if (packageManagerAvailable(pm)) return pm;
|
|
26
|
+
console.error("error: No package manager found (probed pnpm, then npm). Install one of them, then run the install step manually inside the project directory.");
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { detectPackageManager };
|
package/src/template-builder.js
CHANGED
|
@@ -1,186 +1,90 @@
|
|
|
1
|
-
import { CREATE_VERSION, VITE_STARTER_PIN } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
// registry publication are never blocked by the scaffold itself (L11).
|
|
1
|
+
import { CREATE_VERSION, VITE_STARTER_PIN } from "./version.js";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
//#region src/template-builder.ts
|
|
5
4
|
const MAX_PROJECT_NAME_LENGTH = 214;
|
|
6
5
|
const PROJECT_NAME_PATTERN = /^[a-z0-9][a-z0-9._-]*$/;
|
|
7
6
|
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (name !== name.toLowerCase()) {
|
|
20
|
-
return 'Project name must be lowercase (npm package names cannot contain uppercase letters).';
|
|
21
|
-
}
|
|
22
|
-
if (!PROJECT_NAME_PATTERN.test(name)) {
|
|
23
|
-
return 'Project name must start with a lowercase letter or number and may only contain ' + 'lowercase letters, numbers, dots, underscores, and hyphens.';
|
|
24
|
-
}
|
|
25
|
-
return null;
|
|
7
|
+
* L11: validate the scaffold target name before any filesystem work. Returns
|
|
8
|
+
* an actionable message when the name is unsafe, `null` when it is a legal
|
|
9
|
+
* npm-style package name that cannot escape the current directory.
|
|
10
|
+
*/
|
|
11
|
+
function validateProjectName(name) {
|
|
12
|
+
if (name.length === 0) return "Project name must not be empty.";
|
|
13
|
+
if (name.length > MAX_PROJECT_NAME_LENGTH) return `Project name must be at most ${MAX_PROJECT_NAME_LENGTH} characters (npm package-name limit).`;
|
|
14
|
+
if (name.includes("..")) return "Project name must not contain \"..\" (path traversal is not allowed).";
|
|
15
|
+
if (name !== name.toLowerCase()) return "Project name must be lowercase (npm package names cannot contain uppercase letters).";
|
|
16
|
+
if (!PROJECT_NAME_PATTERN.test(name)) return "Project name must start with a lowercase letter or number and may only contain lowercase letters, numbers, dots, underscores, and hyphens.";
|
|
17
|
+
return null;
|
|
26
18
|
}
|
|
27
19
|
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
20
|
+
* The published starter relies on the support-package same-version release
|
|
21
|
+
* invariant. Package-graph and release-prepare gates verify that invariant;
|
|
22
|
+
* Create deliberately has no runtime registry fallback or mixed-version mode.
|
|
23
|
+
* Caller-supplied versions are validated by `buildTemplates` below.
|
|
24
|
+
*/
|
|
25
|
+
function resolveVersions() {
|
|
26
|
+
return {
|
|
27
|
+
router: CREATE_VERSION,
|
|
28
|
+
element: CREATE_VERSION
|
|
29
|
+
};
|
|
37
30
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (observed.length !== 1) {
|
|
43
|
-
throw new Error(`Create requires the support-package same-version release invariant; observed ${observed.join(', ')}`);
|
|
44
|
-
}
|
|
45
|
-
return versions;
|
|
31
|
+
function assertUnifiedProductVersions(versions) {
|
|
32
|
+
const observed = [...new Set(Object.values(versions))];
|
|
33
|
+
if (observed.length !== 1) throw new Error(`Create requires the support-package same-version release invariant; observed ${observed.join(", ")}`);
|
|
34
|
+
return versions;
|
|
46
35
|
}
|
|
47
|
-
// [sourceTemplate, targetRelativePath] pairs. The starter manifest is stored
|
|
48
|
-
// as deno.json.tmpl so deno does not treat the templates/ directory as a
|
|
49
|
-
// nested workspace config; it is renamed to deno.json when written.
|
|
50
36
|
const TEMPLATE_FILES = [
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
[
|
|
78
|
-
'vite.config.ts.tmpl',
|
|
79
|
-
'vite.config.ts'
|
|
80
|
-
],
|
|
81
|
-
[
|
|
82
|
-
'app/islands/app-shell.tsx.tmpl',
|
|
83
|
-
'app/islands/app-shell.tsx'
|
|
84
|
-
],
|
|
85
|
-
[
|
|
86
|
-
'app/components/page-styles.ts.tmpl',
|
|
87
|
-
'app/components/page-styles.ts'
|
|
88
|
-
],
|
|
89
|
-
[
|
|
90
|
-
'app/components/page-home.tsx.tmpl',
|
|
91
|
-
'app/components/page-home.tsx'
|
|
92
|
-
],
|
|
93
|
-
[
|
|
94
|
-
'app/components/page-freshness.tsx.tmpl',
|
|
95
|
-
'app/components/page-freshness.tsx'
|
|
96
|
-
],
|
|
97
|
-
[
|
|
98
|
-
'app/components/page-404.tsx.tmpl',
|
|
99
|
-
'app/components/page-404.tsx'
|
|
100
|
-
],
|
|
101
|
-
[
|
|
102
|
-
'app/components/page-contact.tsx.tmpl',
|
|
103
|
-
'app/components/page-contact.tsx'
|
|
104
|
-
],
|
|
105
|
-
[
|
|
106
|
-
'app/components/page-blog-index.tsx.tmpl',
|
|
107
|
-
'app/components/page-blog-index.tsx'
|
|
108
|
-
],
|
|
109
|
-
[
|
|
110
|
-
'app/components/page-blog-welcome.tsx.tmpl',
|
|
111
|
-
'app/components/page-blog-welcome.tsx'
|
|
112
|
-
],
|
|
113
|
-
[
|
|
114
|
-
'app/routes/404.tsx.tmpl',
|
|
115
|
-
'app/routes/404.tsx'
|
|
116
|
-
],
|
|
117
|
-
[
|
|
118
|
-
'app/routes/index.tsx.tmpl',
|
|
119
|
-
'app/routes/index.tsx'
|
|
120
|
-
],
|
|
121
|
-
[
|
|
122
|
-
'app/routes/freshness.tsx.tmpl',
|
|
123
|
-
'app/routes/freshness.tsx'
|
|
124
|
-
],
|
|
125
|
-
[
|
|
126
|
-
'app/routes/contact.tsx.tmpl',
|
|
127
|
-
'app/routes/contact.tsx'
|
|
128
|
-
],
|
|
129
|
-
[
|
|
130
|
-
'app/routes/blog/index.tsx.tmpl',
|
|
131
|
-
'app/routes/blog/index.tsx'
|
|
132
|
-
],
|
|
133
|
-
[
|
|
134
|
-
'app/routes/blog/welcome.tsx.tmpl',
|
|
135
|
-
'app/routes/blog/welcome.tsx'
|
|
136
|
-
],
|
|
137
|
-
[
|
|
138
|
-
'app/routes/api/health.ts.tmpl',
|
|
139
|
-
'app/routes/api/health.ts'
|
|
140
|
-
],
|
|
141
|
-
[
|
|
142
|
-
'app/islands/my-counter.tsx.tmpl',
|
|
143
|
-
'app/islands/my-counter.tsx'
|
|
144
|
-
],
|
|
145
|
-
[
|
|
146
|
-
'app/islands/only-ticker.tsx.tmpl',
|
|
147
|
-
'app/islands/only-ticker.tsx'
|
|
148
|
-
]
|
|
37
|
+
["gitignore.tmpl", ".gitignore"],
|
|
38
|
+
["README.tmpl", "README.md"],
|
|
39
|
+
["public/openelement-mark.svg", "public/openelement-mark.svg"],
|
|
40
|
+
["package.json.tmpl", "package.json"],
|
|
41
|
+
["tsconfig.json.tmpl", "tsconfig.json"],
|
|
42
|
+
["vite.config.ts.tmpl", "vite.config.ts"],
|
|
43
|
+
["openelement.config.ts.tmpl", "openelement.config.ts"],
|
|
44
|
+
["app/styles/theme.css", "app/styles/theme.css"],
|
|
45
|
+
["app/styles/recipes.css", "app/styles/recipes.css"],
|
|
46
|
+
["app/head.tsx.tmpl", "app/head.tsx"],
|
|
47
|
+
["app/components/page-home.css", "app/components/page-home.css"],
|
|
48
|
+
["app/components/page-about.css", "app/components/page-about.css"],
|
|
49
|
+
["app/components/page-404.css", "app/components/page-404.css"],
|
|
50
|
+
["app/components/badges.css", "app/components/badges.css"],
|
|
51
|
+
["app/components/site-chrome.css", "app/components/site-chrome.css"],
|
|
52
|
+
["app/components/page-home.tsx.tmpl", "app/components/page-home.tsx"],
|
|
53
|
+
["app/components/page-about.tsx.tmpl", "app/components/page-about.tsx"],
|
|
54
|
+
["app/components/page-404.tsx.tmpl", "app/components/page-404.tsx"],
|
|
55
|
+
["app/routes/index.tsx.tmpl", "app/routes/index.tsx"],
|
|
56
|
+
["app/routes/about.tsx.tmpl", "app/routes/about.tsx"],
|
|
57
|
+
["app/routes/404.tsx.tmpl", "app/routes/404.tsx"],
|
|
58
|
+
["app/routes/api/ping.ts.tmpl", "app/routes/api/ping.ts"],
|
|
59
|
+
["app/islands/my-counter.tsx.tmpl", "app/islands/my-counter.tsx"],
|
|
60
|
+
["app/islands/my-counter.css", "app/islands/my-counter.css"],
|
|
61
|
+
["app/islands/live-timer.tsx.tmpl", "app/islands/live-timer.tsx"],
|
|
62
|
+
["app/islands/live-timer.css", "app/islands/live-timer.css"]
|
|
149
63
|
];
|
|
150
64
|
function versionTokens(v) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
65
|
+
return {
|
|
66
|
+
["${v.router}"]: v.router,
|
|
67
|
+
["${v.element}"]: v.element
|
|
68
|
+
};
|
|
155
69
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
throw new Error(`Unresolved scaffold token in starter template: ${source}`);
|
|
175
|
-
}
|
|
176
|
-
return [
|
|
177
|
-
target,
|
|
178
|
-
content
|
|
179
|
-
];
|
|
180
|
-
}));
|
|
181
|
-
// Code-unit comparison (not localeCompare): deterministic across host
|
|
182
|
-
// locales and matches the test's toSorted() expectation, including
|
|
183
|
-
// uppercase targets like README.md.
|
|
184
|
-
entries.sort(([a], [b])=>a < b ? -1 : a > b ? 1 : 0);
|
|
185
|
-
return Object.fromEntries(entries);
|
|
70
|
+
async function buildTemplates(v, projectName) {
|
|
71
|
+
assertUnifiedProductVersions(v);
|
|
72
|
+
const invalid = validateProjectName(projectName);
|
|
73
|
+
if (invalid) throw new Error(`Invalid project name "${projectName}". ${invalid}`);
|
|
74
|
+
const templatesBase = new URL("../templates/", import.meta.url);
|
|
75
|
+
const tokens = {
|
|
76
|
+
...versionTokens(v),
|
|
77
|
+
["${v.vite}"]: VITE_STARTER_PIN,
|
|
78
|
+
["${name}"]: projectName
|
|
79
|
+
};
|
|
80
|
+
const entries = await Promise.all(TEMPLATE_FILES.map(async ([source, target]) => {
|
|
81
|
+
let content = await readFile(new URL(source, templatesBase), "utf8");
|
|
82
|
+
for (const [token, value] of Object.entries(tokens)) if (content.includes(token)) content = content.split(token).join(value);
|
|
83
|
+
if (content.includes("${v.") || content.includes("${name}")) throw new Error(`Unresolved scaffold token in starter template: ${source}`);
|
|
84
|
+
return [target, content];
|
|
85
|
+
}));
|
|
86
|
+
const out = Object.fromEntries(entries);
|
|
87
|
+
return Object.fromEntries(Object.entries(out).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0));
|
|
186
88
|
}
|
|
89
|
+
//#endregion
|
|
90
|
+
export { assertUnifiedProductVersions, buildTemplates, resolveVersions, validateProjectName };
|
package/src/version.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/version.ts
|
|
2
|
+
/** The published CLI version, embedded so packed npm installs are self-contained. */
|
|
3
|
+
const CREATE_VERSION = "1.0.0-alpha.11";
|
|
2
4
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
* The Vite release pinned into the generated starter's package.json (the
|
|
6
|
+
* `${v.vite}` scaffold token in the npm/pnpm starter). Embedded for the same
|
|
7
|
+
* reason as CREATE_VERSION (packed npm installs are self-contained); the
|
|
8
|
+
* repository's Vite-pin check (deps:vite-check in the repo tooling package) anchors this copy
|
|
9
|
+
* to the canonical dev pin.
|
|
10
|
+
*/
|
|
11
|
+
const VITE_STARTER_PIN = "8.0.16";
|
|
12
|
+
//#endregion
|
|
13
|
+
export { CREATE_VERSION, VITE_STARTER_PIN };
|
package/templates/README.tmpl
CHANGED
|
@@ -1,54 +1,117 @@
|
|
|
1
|
-
#
|
|
1
|
+
# openElement Showcase
|
|
2
2
|
|
|
3
|
-
Generated by [`@openelement/create`](https://www.npmjs.com/package/@openelement/create)
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
Generated by [`@openelement/create`](https://www.npmjs.com/package/@openelement/create) —
|
|
4
|
+
scaffold it elsewhere with `npm create @openelement@1.0.0-alpha.10 <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 at all. The badge on each
|
|
9
|
+
section names what it costs the client.
|
|
10
|
+
|
|
11
|
+
Docs and guides: https://openelement.org
|
|
12
|
+
|
|
13
|
+
One directory is generated rather than source: `.openElement/` at the project
|
|
14
|
+
root holds the build's internal state (head-convention bookkeeping and build
|
|
15
|
+
plans). `pnpm dev` and `pnpm build` write it as needed; the `.gitignore`
|
|
16
|
+
excludes it and deleting it is safe — the next run recreates it.
|
|
7
17
|
|
|
8
18
|
This starter pins the exact `@openelement/element` and `@openelement/router`
|
|
9
|
-
versions it was generated from
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
`
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
19
|
+
versions it was generated from in `package.json`; update both there when
|
|
20
|
+
moving to a new release.
|
|
21
|
+
|
|
22
|
+
## The JS cost map
|
|
23
|
+
|
|
24
|
+
| Surface | Ships JavaScript? | Why |
|
|
25
|
+
| --- | --- | --- |
|
|
26
|
+
| `/` hero + architecture sections | no | prerendered markup, styled with CSS |
|
|
27
|
+
| `/` counter island (`my-counter`) | yes, hydrates on idle | the one interactive piece |
|
|
28
|
+
| `/` live timer island (`live-timer`) | yes, client-only | a live clock has nothing to prerender |
|
|
29
|
+
| `/about` | no islands at all | fully static SSG output |
|
|
30
|
+
| `/api/ping` | no (server) | a plain `Request → Response` handler |
|
|
31
|
+
|
|
32
|
+
The badge classes (`badge-static`, `badge-island`) live in
|
|
33
|
+
`app/components/badges.css` — copy them onto new sections and keep the
|
|
34
|
+
map honest.
|
|
35
|
+
|
|
36
|
+
> Cost honesty: the island client is emitted app-wide today. A page without
|
|
37
|
+
> islands (like `/about`) carries no island hosts and renders nothing
|
|
38
|
+
> interactive, but the shared loader — and with the current app-wide
|
|
39
|
+
> hydration manifest, the island chunks themselves — still ride along in its
|
|
40
|
+
> network panel. Per-page pruning is framework work, not something a template
|
|
41
|
+
> can opt into; the page is authored so it becomes fully silent the moment
|
|
42
|
+
> the framework ships it.
|
|
43
|
+
|
|
44
|
+
## Where things live
|
|
45
|
+
|
|
46
|
+
Framework options have exactly one home: `openelement.config.ts`. It is
|
|
47
|
+
optional and nearly empty — every option it omits comes from a file
|
|
48
|
+
convention:
|
|
49
|
+
|
|
50
|
+
| Option | Convention |
|
|
51
|
+
| --- | --- |
|
|
52
|
+
| design tokens | `app/styles/theme.css` (the @theme role sheet) |
|
|
53
|
+
| document head content | `app/head.tsx` (meta tags, preloads, inline CSS) |
|
|
54
|
+
| site title | the `name` field of `package.json` |
|
|
55
|
+
| static-shape recipes | `app/styles/recipes.css` (zero-interaction badge/callout/card/tabs shapes as plain HTML+CSS — the @openelement/ui components retired to these recipes in #1557) |
|
|
56
|
+
|
|
57
|
+
Passing framework options inline to `openElement()` while the config file
|
|
58
|
+
carries options is a hard error, and an unknown key fails the build with the
|
|
59
|
+
accepted-key list. `vite.config.ts` stays Vite-only: `plugins: [...openElement()]`.
|
|
60
|
+
|
|
61
|
+
- `app/routes/` — page routes, one file per URL. The default renderIntent is
|
|
62
|
+
`static`: prerendered at build time (SSG). `/about` and `/` are static.
|
|
63
|
+
- `app/routes/api/` — request-time server routes. `/api/ping` is a plain
|
|
64
|
+
WinterCG-shaped handler returning `Response.json`.
|
|
65
|
+
- `app/components/` — compiled page elements and their style sheets
|
|
66
|
+
(page CSS lives in `.css` files next to each element; pages import and
|
|
67
|
+
array them in `static styles`, sharing `site-chrome.css`/`badges.css`).
|
|
68
|
+
- `app/islands/` — client islands, the only code that ships JavaScript. Each
|
|
69
|
+
island declares its hydration strategy (`idle`, `load`, `visible`,
|
|
70
|
+
client-only) through `defineIslandConfig`.
|
|
71
|
+
- `app/styles/theme.css` — the @theme role sheet: Tailwind-ON roles, the starter palette aliases, dark and forced-colors pairs. Dev serves it directly; the build compiles it through the router's Tailwind preset.
|
|
72
|
+
Dark values ride `prefers-color-scheme`; no theme runtime.
|
|
73
|
+
- `app/styles/recipes.css` — documented plain HTML+CSS recipes for the
|
|
74
|
+
zero-interaction shapes (badge, callout, card, CSS-only tabs) that retired
|
|
75
|
+
from `@openelement/ui` (#1557). Delete the blocks you do not use: static
|
|
76
|
+
content never justifies a custom element.
|
|
77
|
+
- `app/head.tsx` — structural head content the URL list cannot express.
|
|
78
|
+
|
|
79
|
+
## Scripts
|
|
80
|
+
|
|
81
|
+
- `pnpm dev` — start the Vite dev server.
|
|
82
|
+
- `pnpm check` — type-check every route/component file. The check covers the
|
|
83
|
+
whole `app/` directory (`tsconfig.json`), so new files are picked up
|
|
84
|
+
automatically.
|
|
85
|
+
- `pnpm test` — run Node's built-in test runner (the starter ships none).
|
|
86
|
+
- `pnpm build` — production build (SSG + Nitro server) into `dist/`.
|
|
87
|
+
- `pnpm start` — serve the production build.
|
|
88
|
+
- `pnpm preview` — static-only preview of the SSG output.
|
|
89
|
+
|
|
90
|
+
## Styling ownership
|
|
91
|
+
|
|
92
|
+
Global design tokens and the document baseline (`body`, `::selection`) live
|
|
93
|
+
in `app/styles/theme.css`. Pages use light roots and own their rules in
|
|
94
|
+
`static styles`, arrayed from imported `.css` files (#1558 — the one style
|
|
95
|
+
authoring form): the server inlines each page's sheets into the SSR output as
|
|
96
|
+
a `@scope(<page-tag>)` style block, so pages are fully styled with zero
|
|
97
|
+
client JavaScript. Islands carry their own `.css` sheets the same way; in
|
|
98
|
+
island chunks those ride the style-asset protocol as real `.css` assets.
|
|
50
99
|
|
|
51
100
|
## Brand assets
|
|
52
101
|
|
|
53
102
|
`public/openelement-mark.svg` is the openElement brand mark shipped with the
|
|
54
|
-
starter —
|
|
103
|
+
starter — the config file references it as the favicon, or delete it if
|
|
104
|
+
unused.
|
|
105
|
+
|
|
106
|
+
## Dependency notes
|
|
107
|
+
|
|
108
|
+
`@hono/vite-dev-server` is installed even though no source file imports it:
|
|
109
|
+
the Vite dev server needs it, and it is loaded lazily, so `build`/`start`
|
|
110
|
+
never resolve it. `hono` rides along because the dev server's own node
|
|
111
|
+
adapter declares it a peer. The generated server entry itself imports no
|
|
112
|
+
HTTP framework — it composes on the internal WinterCG layer (#1560); `hono`
|
|
113
|
+
is an optional peer of `@openelement/router`, and `@openelement/router/hono`
|
|
114
|
+
(`createHonoAdapter`) is the one opt-in if you ever want to mount the built
|
|
115
|
+
handler inside your own Hono app. For Nitro deployments, the built handler
|
|
116
|
+
bridges through the `@openelement/router/nitro-mount` subpath of the one
|
|
117
|
+
`@openelement/router` dependency. Do not remove them.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
|
|
2
|
+
.badge { display: inline-flex; align-items: center; gap: 0.4em; padding: 0.2rem 0.65rem; border-radius: 999px; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; border: 1px solid var(--line); color: var(--ink-soft); background: var(--surface); }
|
|
3
|
+
.badge-static { border-color: color-mix(in srgb, var(--ok) 35%, transparent); color: var(--ok); background: color-mix(in srgb, var(--ok) 8%, transparent); }
|
|
4
|
+
.badge-island { border-color: color-mix(in srgb, var(--brand) 40%, transparent); color: var(--brand); background: var(--brand-soft); }
|
|
5
|
+
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
|
|
2
|
+
:host { display: block; }
|
|
3
|
+
h1 { font-size: 2.4rem; letter-spacing: -0.02em; margin: 0.75rem 0 0.5rem; font-weight: 700; }
|
|
4
|
+
p { color: var(--ink-soft); line-height: 1.6; }
|
|
5
|
+
a { color: var(--brand); font-weight: 600; text-decoration: none; }
|
|
6
|
+
a:hover { text-decoration: underline; }
|
|
7
|
+
|
|
@@ -2,25 +2,46 @@
|
|
|
2
2
|
* Styled 404 page element (#923): the request-time server renders this page
|
|
3
3
|
* with a 404 status for unmatched paths; SSG builds also emit it as static
|
|
4
4
|
* 404.html. The path-derived tag is 'el-404'. Light root: the page owns its
|
|
5
|
-
* rules via `static styles` (
|
|
6
|
-
* @scope(el-404).
|
|
5
|
+
* rules via `static styles` (the imported .css sheets), inlined into SSR as
|
|
6
|
+
* @scope(el-404). The site chrome sheet (./site-chrome.css) is shared
|
|
7
7
|
*/
|
|
8
8
|
import { element, OpenElement } from '@openelement/element';
|
|
9
|
-
import
|
|
9
|
+
import notFoundPageStyles from './page-404.css';
|
|
10
|
+
import siteChromeStyles from './site-chrome.css';
|
|
10
11
|
|
|
11
12
|
@element('el-404', { root: 'light' })
|
|
12
13
|
export default class NotFoundPage extends OpenElement {
|
|
13
|
-
static override styles = notFoundPageStyles;
|
|
14
|
+
static override styles = [notFoundPageStyles, siteChromeStyles];
|
|
14
15
|
|
|
15
16
|
render() {
|
|
16
17
|
return (
|
|
17
|
-
<
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
<div class='page-body'>
|
|
19
|
+
<header class='site-head'>
|
|
20
|
+
<div class='bar'>
|
|
21
|
+
<a class='site-brand' href='/'>
|
|
22
|
+
openElement
|
|
23
|
+
</a>
|
|
24
|
+
<nav>
|
|
25
|
+
<a href='/'>Home</a>
|
|
26
|
+
<a href='/about'>About</a>
|
|
27
|
+
<a href='/api/ping'>API</a>
|
|
28
|
+
</nav>
|
|
29
|
+
</div>
|
|
30
|
+
</header>
|
|
31
|
+
<main>
|
|
32
|
+
<h1>404</h1>
|
|
33
|
+
<p>The page you are looking for does not exist.</p>
|
|
34
|
+
<p>
|
|
35
|
+
<a href='/'>Back to the homepage</a>
|
|
36
|
+
</p>
|
|
37
|
+
</main>
|
|
38
|
+
<footer class='site-foot'>
|
|
39
|
+
<div class='bar'>
|
|
40
|
+
<span>Generated by @openelement/create.</span>
|
|
41
|
+
<a href='https://openelement.org'>openelement.org</a>
|
|
42
|
+
</div>
|
|
43
|
+
</footer>
|
|
44
|
+
</div>
|
|
24
45
|
);
|
|
25
46
|
}
|
|
26
47
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
:host { display: block; }
|
|
3
|
+
.eyebrow { color: var(--brand); font-weight: 600; font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase; margin: 0; }
|
|
4
|
+
h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); line-height: 1.15; letter-spacing: -0.02em; margin: 0.75rem 0 1rem; font-weight: 700; }
|
|
5
|
+
.lede { font-size: 1.08rem; color: var(--ink-soft); max-width: 58ch; margin: 0 0 2rem; }
|
|
6
|
+
h2 { font-size: 1.25rem; letter-spacing: -0.01em; margin: 2.25rem 0 0.6rem; }
|
|
7
|
+
p { margin: 0.6rem 0; max-width: 62ch; }
|
|
8
|
+
p code, li code { font-family: var(--font-mono); font-size: 0.85em; background: var(--surface); border: 1px solid var(--line); border-radius: 5px; padding: 0.08em 0.35em; }
|
|
9
|
+
.conventions { list-style: none; margin: 1rem 0 0; padding: 0; border-top: 1px solid var(--line); }
|
|
10
|
+
.conventions li { display: flex; gap: 1rem; padding: 0.7rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
|
|
11
|
+
.conventions code { font-family: var(--font-mono); font-size: 0.85rem; color: var(--brand); min-width: 15rem; }
|
|
12
|
+
.conventions span { color: var(--ink-soft); font-size: 0.92rem; }
|
|
13
|
+
a { color: var(--brand); text-decoration: none; }
|
|
14
|
+
a:hover { text-decoration: underline; }
|
|
15
|
+
|