@openelement/create 1.0.0-alpha.1 → 1.0.0-alpha.10
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 +90 -24
- package/package.json +15 -4
- package/src/cli.d.ts +1 -1
- package/src/cli.js +122 -65
- package/src/install-command.d.ts +50 -0
- package/src/install-command.js +52 -0
- package/src/template-builder.js +128 -174
- package/src/version.js +22 -6
- package/templates/README.tmpl +52 -25
- package/templates/app/components/page-blog-welcome.tsx.tmpl +1 -1
- package/templates/app/components/page-home.tsx.tmpl +1 -1
- package/templates/app/components/page-styles.ts.tmpl +21 -64
- package/templates/app/head.tsx.tmpl +42 -0
- package/templates/app/islands/app-shell.tsx.tmpl +36 -11
- package/templates/app/islands/my-counter.tsx.tmpl +19 -2
- package/templates/app/islands/only-ticker.tsx.tmpl +19 -2
- package/templates/app/styles/tokens.css +57 -0
- package/templates/gitignore.tmpl +1 -0
- package/templates/openelement.config.ts.tmpl +31 -0
- package/templates/package.json.tmpl +24 -1
- package/templates/tailwind/theme.css +108 -0
- package/templates/tailwind/vite.config.ts.tmpl +38 -0
- package/templates/tsconfig.json.tmpl +15 -0
- package/templates/vite.config.ts.tmpl +6 -32
- package/templates/deno.json.tmpl +0 -25
package/src/template-builder.js
CHANGED
|
@@ -1,186 +1,140 @@
|
|
|
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, TAILWIND_STARTER_PIN, 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/tokens.css", "app/styles/tokens.css"],
|
|
45
|
+
["app/head.tsx.tmpl", "app/head.tsx"],
|
|
46
|
+
["app/islands/app-shell.tsx.tmpl", "app/islands/app-shell.tsx"],
|
|
47
|
+
["app/components/page-styles.ts.tmpl", "app/components/page-styles.ts"],
|
|
48
|
+
["app/components/page-home.tsx.tmpl", "app/components/page-home.tsx"],
|
|
49
|
+
["app/components/page-freshness.tsx.tmpl", "app/components/page-freshness.tsx"],
|
|
50
|
+
["app/components/page-404.tsx.tmpl", "app/components/page-404.tsx"],
|
|
51
|
+
["app/components/page-contact.tsx.tmpl", "app/components/page-contact.tsx"],
|
|
52
|
+
["app/components/page-blog-index.tsx.tmpl", "app/components/page-blog-index.tsx"],
|
|
53
|
+
["app/components/page-blog-welcome.tsx.tmpl", "app/components/page-blog-welcome.tsx"],
|
|
54
|
+
["app/routes/404.tsx.tmpl", "app/routes/404.tsx"],
|
|
55
|
+
["app/routes/index.tsx.tmpl", "app/routes/index.tsx"],
|
|
56
|
+
["app/routes/freshness.tsx.tmpl", "app/routes/freshness.tsx"],
|
|
57
|
+
["app/routes/contact.tsx.tmpl", "app/routes/contact.tsx"],
|
|
58
|
+
["app/routes/blog/index.tsx.tmpl", "app/routes/blog/index.tsx"],
|
|
59
|
+
["app/routes/blog/welcome.tsx.tmpl", "app/routes/blog/welcome.tsx"],
|
|
60
|
+
["app/routes/api/health.ts.tmpl", "app/routes/api/health.ts"],
|
|
61
|
+
["app/islands/my-counter.tsx.tmpl", "app/islands/my-counter.tsx"],
|
|
62
|
+
["app/islands/only-ticker.tsx.tmpl", "app/islands/only-ticker.tsx"]
|
|
149
63
|
];
|
|
64
|
+
/**
|
|
65
|
+
* The Tailwind-ON overlay (#1524): the default scaffold replaces the plain
|
|
66
|
+
* vite config with the preset-wired one and adds the @theme role sheet. The
|
|
67
|
+
* overlay lives in templates/tailwind/ so the OFF form stays exactly the
|
|
68
|
+
* pre-#1524 minimal starter. theme.css carries no scaffold tokens (like
|
|
69
|
+
* tokens.css), so it ships as a plain payload file.
|
|
70
|
+
*/
|
|
71
|
+
const TAILWIND_TEMPLATE_FILES = [["tailwind/vite.config.ts.tmpl", "vite.config.ts"], ["tailwind/theme.css", "app/styles/theme.css"]];
|
|
72
|
+
/** The README section token the Tailwind-ON prose replaces (OFF removes it). */
|
|
73
|
+
const TAILWIND_README_TOKEN = "${tailwind.section}";
|
|
74
|
+
/** The devDependencies the Tailwind-ON scaffold adds (exact pins, no ranges). */
|
|
75
|
+
const TAILWIND_DEV_DEPENDENCIES = {
|
|
76
|
+
"@tailwindcss/vite": TAILWIND_STARTER_PIN,
|
|
77
|
+
tailwindcss: TAILWIND_STARTER_PIN
|
|
78
|
+
};
|
|
150
79
|
function versionTokens(v) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
80
|
+
return {
|
|
81
|
+
["${v.router}"]: v.router,
|
|
82
|
+
["${v.element}"]: v.element
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
async function buildTemplates(v, projectName, options = {}) {
|
|
86
|
+
assertUnifiedProductVersions(v);
|
|
87
|
+
const invalid = validateProjectName(projectName);
|
|
88
|
+
if (invalid) throw new Error(`Invalid project name "${projectName}". ${invalid}`);
|
|
89
|
+
const tailwind = options.tailwind ?? true;
|
|
90
|
+
const templatesBase = new URL("../templates/", import.meta.url);
|
|
91
|
+
const tokens = {
|
|
92
|
+
...versionTokens(v),
|
|
93
|
+
["${v.vite}"]: VITE_STARTER_PIN,
|
|
94
|
+
["${name}"]: projectName,
|
|
95
|
+
[TAILWIND_README_TOKEN]: tailwind ? tailwindReadmeSection() : ""
|
|
96
|
+
};
|
|
97
|
+
const files = tailwind ? [...TEMPLATE_FILES, ...TAILWIND_TEMPLATE_FILES] : TEMPLATE_FILES;
|
|
98
|
+
const entries = await Promise.all(files.map(async ([source, target]) => {
|
|
99
|
+
let content = await readFile(new URL(source, templatesBase), "utf8");
|
|
100
|
+
for (const [token, value] of Object.entries(tokens)) if (content.includes(token)) content = content.split(token).join(value);
|
|
101
|
+
if (content.includes("${v.") || content.includes("${name}") || content.includes("${tailwind.")) throw new Error(`Unresolved scaffold token in starter template: ${source}`);
|
|
102
|
+
return [target, content];
|
|
103
|
+
}));
|
|
104
|
+
const byTarget = new Map(entries);
|
|
105
|
+
if (tailwind) {
|
|
106
|
+
const manifestPath = "package.json";
|
|
107
|
+
const manifest = JSON.parse(byTarget.get(manifestPath));
|
|
108
|
+
manifest.devDependencies = Object.fromEntries(Object.entries({
|
|
109
|
+
...manifest.devDependencies,
|
|
110
|
+
...TAILWIND_DEV_DEPENDENCIES
|
|
111
|
+
}).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0));
|
|
112
|
+
byTarget.set(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`);
|
|
113
|
+
}
|
|
114
|
+
const out = Object.fromEntries(byTarget);
|
|
115
|
+
return Object.fromEntries(Object.entries(out).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0));
|
|
155
116
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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);
|
|
117
|
+
/**
|
|
118
|
+
* The README prose the Tailwind-ON scaffold injects (the OFF form removes the
|
|
119
|
+
* token line). One source here, so the generated README and the tests cannot
|
|
120
|
+
* drift apart. The leading/trailing newline keeps the injected heading
|
|
121
|
+
* blank-line separated in both replacements.
|
|
122
|
+
*/
|
|
123
|
+
function tailwindReadmeSection() {
|
|
124
|
+
return `
|
|
125
|
+
## Tailwind and the @theme role sheet
|
|
126
|
+
|
|
127
|
+
This project was scaffolded with Tailwind enabled (pass \`--no-tailwind\` to
|
|
128
|
+
\`@openelement/create\` for a starter without it). \`app/styles/theme.css\` is
|
|
129
|
+
the @theme role sheet: semantic roles (background, primary, muted, ...) over
|
|
130
|
+
the Tailwind default scale, with dark pairs and a forced-colors layer. The
|
|
131
|
+
router's Tailwind preset compiles the sheet into one linked bundle during
|
|
132
|
+
\`pnpm build\` and references it from every rendered page; the custom
|
|
133
|
+
properties inherit into every shadow root, so pages and islands can consume
|
|
134
|
+
the roles directly. \`pnpm dev\` serves the tokens convention instead — the
|
|
135
|
+
compiled bundle exists in the build output. Extend the sheet by adding role
|
|
136
|
+
lines; \`@openelement/ui\`'s theme.css documents the same contract.
|
|
137
|
+
`;
|
|
186
138
|
}
|
|
139
|
+
//#endregion
|
|
140
|
+
export { TAILWIND_DEV_DEPENDENCIES, TAILWIND_README_TOKEN, assertUnifiedProductVersions, buildTemplates, resolveVersions, validateProjectName };
|
package/src/version.js
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
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.10";
|
|
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
|
+
/**
|
|
13
|
+
* The Tailwind line pinned into the generated starter's devDependencies (the
|
|
14
|
+
* Tailwind-ON scaffold, #1524): both `tailwindcss` and `@tailwindcss/vite`,
|
|
15
|
+
* exactly, aligned with the router's own dev pins. The 4.3.x line is the
|
|
16
|
+
* preset's supported line (the v3-lts line is forbidden — see the router's
|
|
17
|
+
* preset-tailwind module). Embedded like the other pins so packed npm
|
|
18
|
+
* installs stay self-contained; the create tests anchor this copy to the
|
|
19
|
+
* router manifest the way deps:vite-check anchors VITE_STARTER_PIN.
|
|
20
|
+
*/
|
|
21
|
+
const TAILWIND_STARTER_PIN = "4.3.3";
|
|
22
|
+
//#endregion
|
|
23
|
+
export { CREATE_VERSION, TAILWIND_STARTER_PIN, VITE_STARTER_PIN };
|
package/templates/README.tmpl
CHANGED
|
@@ -5,29 +5,57 @@ A file-based openElement app: page routes live in `app/routes/`, compiled page
|
|
|
5
5
|
elements and shared style sheets in `app/components/`, and client islands
|
|
6
6
|
(including the `app-shell` layout island) in `app/islands/`.
|
|
7
7
|
|
|
8
|
+
One directory is generated rather than source: `.openElement/` at the project
|
|
9
|
+
root holds the build's internal state. The router compiles the `app/head.tsx`
|
|
10
|
+
head convention there (build-plan bookkeeping and Tailwind preset staging land
|
|
11
|
+
alongside); `pnpm dev` and `pnpm build` write it as needed. The starter's
|
|
12
|
+
`.gitignore` excludes it, and deleting it is safe — the next dev run or build
|
|
13
|
+
recreates it.
|
|
14
|
+
|
|
8
15
|
This starter pins the exact `@openelement/element` and `@openelement/router`
|
|
9
|
-
versions it was generated from (`${v.element}`) in `
|
|
16
|
+
versions it was generated from (`${v.element}`) in `package.json`; update both
|
|
10
17
|
there when moving to a new release.
|
|
11
18
|
|
|
12
19
|
Styling ownership is split three ways. Global design tokens and the document
|
|
13
|
-
baseline (`body`, `::selection`) live in `
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
page
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
baseline (`body`, `::selection`) live in `app/styles/tokens.css` — the file
|
|
21
|
+
convention the build inlines into every document `<head>`. Pages use light
|
|
22
|
+
roots and own their rules in `static styles`
|
|
23
|
+
(`app/components/page-styles.ts`): the server inlines each page's sheets into
|
|
24
|
+
the SSR output as a `@scope(<page-tag>)` style block, so pages are fully styled
|
|
25
|
+
with zero client JavaScript. The shell and the islands hydrate in the browser
|
|
26
|
+
and carry their own `static styles`.
|
|
27
|
+
${tailwind.section}
|
|
28
|
+
## Where options live
|
|
29
|
+
|
|
30
|
+
Framework options have exactly one home: `openelement.config.ts`. It is
|
|
31
|
+
optional and nearly empty — every option it omits comes from a file
|
|
32
|
+
convention:
|
|
33
|
+
|
|
34
|
+
| Option | Convention |
|
|
35
|
+
| --- | --- |
|
|
36
|
+
| design tokens | `app/styles/tokens.css` |
|
|
37
|
+
| app shell | `app/islands/app-shell.tsx` (deletable) |
|
|
38
|
+
| document head content | `app/head.tsx` (meta tags, preloads, inline CSS) |
|
|
39
|
+
| site title | the `name` field of `package.json` |
|
|
40
|
+
|
|
41
|
+
Passing framework options inline to `openElement()` while the config file
|
|
42
|
+
carries options is a hard error, and an unknown key fails the build with the
|
|
43
|
+
accepted-key list. `vite.config.ts` stays Vite-only: `plugins: [...openElement()]`.
|
|
44
|
+
The conventions follow the `dirs` block, so moving the three roots under
|
|
45
|
+
`src/` moves the token, shell and head files with them.
|
|
46
|
+
|
|
47
|
+
## Scripts
|
|
48
|
+
|
|
49
|
+
- `pnpm dev` — start the Vite dev server.
|
|
50
|
+
- `pnpm check` — type-check every route/component file. The check covers the
|
|
51
|
+
whole `app/` directory (`tsconfig.json`), so new files are picked up
|
|
52
|
+
automatically.
|
|
53
|
+
- `pnpm test` — run Node's built-in test runner (the starter ships none).
|
|
54
|
+
- `pnpm build` — production build (SSG + Nitro server) into `dist/`.
|
|
55
|
+
- `pnpm start` — serve the production build. Use this for production
|
|
28
56
|
preview: the starter ships a request-time route (`/contact`), so
|
|
29
|
-
`
|
|
30
|
-
- `
|
|
57
|
+
`pnpm preview` (static-only preview, #601) is refused by design.
|
|
58
|
+
- `pnpm preview` — static-only preview; refused for this starter (see
|
|
31
59
|
above).
|
|
32
60
|
|
|
33
61
|
## Blog
|
|
@@ -39,14 +67,13 @@ then link it from `app/routes/blog/index.tsx` (the index list is static
|
|
|
39
67
|
authoring). Interactive content belongs in a compiled island composed from
|
|
40
68
|
the page.
|
|
41
69
|
|
|
42
|
-
##
|
|
70
|
+
## Dependency notes
|
|
43
71
|
|
|
44
|
-
`
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
them.
|
|
72
|
+
`hono` and `@hono/vite-dev-server` are installed even though no source file
|
|
73
|
+
imports them: the dev server resolves `hono` when loading the generated
|
|
74
|
+
server entry (the bundled `dist/` output inlines it). For Nitro deployments,
|
|
75
|
+
the built handler bridges through the `@openelement/router/nitro-mount`
|
|
76
|
+
subpath of the one `@openelement/router` dependency. Do not remove them.
|
|
50
77
|
|
|
51
78
|
## Brand assets
|
|
52
79
|
|
|
@@ -38,7 +38,7 @@ export default class BlogWelcomePage extends OpenElement {
|
|
|
38
38
|
</li>
|
|
39
39
|
<li>a request-time route with a plain HTML form loop (/contact)</li>
|
|
40
40
|
<li>client islands hydrated on demand (the counter on the home page)</li>
|
|
41
|
-
<li>an app shell composed around every page
|
|
41
|
+
<li>an app shell composed around every page by the app-shell convention</li>
|
|
42
42
|
</ul>
|
|
43
43
|
<h2>Write your own posts</h2>
|
|
44
44
|
<p>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Home page element — static prerendered (default renderIntent mode).
|
|
3
3
|
*
|
|
4
|
-
* Compiled
|
|
4
|
+
* Compiled page: the render() below is lowered to a Part Program
|
|
5
5
|
* at build time. The page uses a light root and owns its rules via
|
|
6
6
|
* `static styles` (./page-styles.ts): the server inlines them into the SSR
|
|
7
7
|
* output as a @scope(index-page) <style data-oe-static-styles> block, so the
|
|
@@ -1,76 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Style sheets for the starter's compiled elements (v0.44).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
4
|
+
* Page sheets live in this plain module (compiled modules may not carry
|
|
5
|
+
* runtime top-level statements, and page components are not islands). Page
|
|
6
|
+
* elements use light roots: the server inlines their sheets into the SSR
|
|
7
|
+
* output as a @scope(<page-tag>) block (<style data-oe-static-styles>), so
|
|
8
|
+
* pages are styled with zero client JS. Under @scope the host tag prefixes
|
|
9
|
+
* of a document stylesheet are dropped: the page element itself is `:host`
|
|
10
|
+
* and descendant selectors go unprefixed.
|
|
11
|
+
*
|
|
12
|
+
* ISLAND sheets are same-module `compiledStyle()` consts in the island
|
|
13
|
+
* modules under the island style asset protocol — cross-module
|
|
14
|
+
* sheet imports fail closed (OEC9028). This module ships the factory helper
|
|
15
|
+
* the islands spell.
|
|
13
16
|
*/
|
|
14
17
|
import { StyleSheet, type StyleSheetLike } from '@openelement/element';
|
|
15
18
|
|
|
16
|
-
function
|
|
17
|
-
const instance = new StyleSheet();
|
|
19
|
+
export function compiledStyle(css: string): StyleSheetLike {
|
|
20
|
+
const instance: StyleSheetLike = new StyleSheet();
|
|
18
21
|
instance.replaceSync(css);
|
|
19
22
|
return instance;
|
|
20
23
|
}
|
|
21
24
|
|
|
22
|
-
export const shellStyles = [
|
|
23
|
-
sheet(`
|
|
24
|
-
:host { display: block; min-height: 100vh; }
|
|
25
|
-
header { border-bottom: 1px solid var(--line); }
|
|
26
|
-
.bar { max-width: 740px; margin: 0 auto; padding: 1.15rem 1.25rem; display: flex; justify-content: space-between; align-items: baseline; }
|
|
27
|
-
.brand { font-family: var(--font-serif); font-weight: 700; font-size: 1.2rem; letter-spacing: -0.01em; color: var(--ink); }
|
|
28
|
-
.brand:hover { text-decoration: none; color: var(--brand); }
|
|
29
|
-
nav { display: flex; gap: 1.5rem; }
|
|
30
|
-
nav a { color: var(--ink-2); font-size: 0.95rem; font-weight: 500; }
|
|
31
|
-
nav a:hover { color: var(--brand); text-decoration: none; }
|
|
32
|
-
main { max-width: 740px; margin: 0 auto; padding: 3rem 1.25rem 4rem; }
|
|
33
|
-
footer { border-top: 1px solid var(--line); color: var(--ink-2); font-size: 0.85rem; }
|
|
34
|
-
.foot { max-width: 740px; margin: 0 auto; padding: 1.25rem; display: flex; justify-content: space-between; gap: 1rem; }
|
|
35
|
-
a { color: var(--brand); text-decoration: none; }
|
|
36
|
-
a:hover { text-decoration: underline; }
|
|
37
|
-
`),
|
|
38
|
-
];
|
|
39
|
-
|
|
40
|
-
export const counterStyles = [
|
|
41
|
-
sheet(`
|
|
42
|
-
:host { display: inline-block; }
|
|
43
|
-
.counter-row { display: inline-flex; gap: 0.75rem; align-items: center; }
|
|
44
|
-
button {
|
|
45
|
-
width: 2rem; height: 2rem; border: 1px solid var(--line); border-radius: 6px;
|
|
46
|
-
background: #fff; color: var(--ink); font-size: 1rem; line-height: 1; cursor: pointer;
|
|
47
|
-
transition: border-color 0.15s ease, color 0.15s ease;
|
|
48
|
-
}
|
|
49
|
-
button:hover { border-color: var(--brand); color: var(--brand); }
|
|
50
|
-
span { min-width: 2ch; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }
|
|
51
|
-
`),
|
|
52
|
-
];
|
|
53
|
-
|
|
54
|
-
export const tickerStyles = [
|
|
55
|
-
sheet(`
|
|
56
|
-
:host { display: inline-block; }
|
|
57
|
-
.ticker-row { display: inline-flex; gap: 0.75rem; align-items: center; }
|
|
58
|
-
button {
|
|
59
|
-
height: 2rem; padding: 0 0.9rem; border: 1px solid var(--line); border-radius: 6px;
|
|
60
|
-
background: #fff; color: var(--ink); font-size: 0.9rem; cursor: pointer;
|
|
61
|
-
transition: border-color 0.15s ease, color 0.15s ease;
|
|
62
|
-
}
|
|
63
|
-
button:hover { border-color: var(--brand); color: var(--brand); }
|
|
64
|
-
span { min-width: 2ch; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }
|
|
65
|
-
`),
|
|
66
|
-
];
|
|
67
|
-
|
|
68
25
|
// ─── Page sheets (light roots → inlined as @scope(<page-tag>) in SSR) ───
|
|
69
26
|
|
|
70
27
|
// Shared post-list rules (home teaser + blog index) — one source, both pages
|
|
71
28
|
// include this sheet in their `static styles` arrays.
|
|
72
29
|
export const postListStyles = [
|
|
73
|
-
|
|
30
|
+
compiledStyle(`
|
|
74
31
|
.posts { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); }
|
|
75
32
|
.post { display: block; padding: 1.15rem 0; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
|
|
76
33
|
a.post:hover .title { color: var(--brand); }
|
|
@@ -82,7 +39,7 @@ export const postListStyles = [
|
|
|
82
39
|
|
|
83
40
|
// Home page (index-page)
|
|
84
41
|
export const homePageStyles = [
|
|
85
|
-
|
|
42
|
+
compiledStyle(`
|
|
86
43
|
:host { display: block; }
|
|
87
44
|
.hero { padding: 2.5rem 0 1rem; }
|
|
88
45
|
.eyebrow { color: var(--brand); font-weight: 600; font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase; }
|
|
@@ -104,7 +61,7 @@ export const homePageStyles = [
|
|
|
104
61
|
|
|
105
62
|
// Blog index (blog-index)
|
|
106
63
|
export const blogIndexStyles = [
|
|
107
|
-
|
|
64
|
+
compiledStyle(`
|
|
108
65
|
:host { display: block; }
|
|
109
66
|
.eyebrow { color: var(--brand); font-weight: 600; font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase; }
|
|
110
67
|
h1 { font-family: var(--font-serif); letter-spacing: -0.015em; margin: 0.5rem 0; }
|
|
@@ -117,7 +74,7 @@ export const blogIndexStyles = [
|
|
|
117
74
|
|
|
118
75
|
// Blog post page (blog-welcome)
|
|
119
76
|
export const blogWelcomeStyles = [
|
|
120
|
-
|
|
77
|
+
compiledStyle(`
|
|
121
78
|
:host { display: block; }
|
|
122
79
|
h1 { font-family: var(--font-serif); font-size: 2.4rem; line-height: 1.15; letter-spacing: -0.015em; margin: 0.5rem 0; }
|
|
123
80
|
.meta { color: var(--ink-2); font-size: 0.9rem; margin-top: 0; padding-bottom: 1.5rem; border-bottom: 1px solid var(--line); }
|
|
@@ -131,7 +88,7 @@ export const blogWelcomeStyles = [
|
|
|
131
88
|
|
|
132
89
|
// Freshness proof (freshness-page)
|
|
133
90
|
export const freshnessPageStyles = [
|
|
134
|
-
|
|
91
|
+
compiledStyle(`
|
|
135
92
|
:host { display: block; max-width: 800px; margin: 2rem auto; padding: 0 1rem; }
|
|
136
93
|
p { color: var(--ink-2); }
|
|
137
94
|
`),
|
|
@@ -139,7 +96,7 @@ export const freshnessPageStyles = [
|
|
|
139
96
|
|
|
140
97
|
// Styled 404 (el-404)
|
|
141
98
|
export const notFoundPageStyles = [
|
|
142
|
-
|
|
99
|
+
compiledStyle(`
|
|
143
100
|
:host { display: block; }
|
|
144
101
|
h1 { font-family: var(--font-serif); font-size: 2.4rem; letter-spacing: -0.015em; margin: 0.75rem 0 0.5rem; font-weight: 700; }
|
|
145
102
|
p { color: var(--ink-2); line-height: 1.6; }
|
|
@@ -150,7 +107,7 @@ export const notFoundPageStyles = [
|
|
|
150
107
|
|
|
151
108
|
// Contact form (contact-page)
|
|
152
109
|
export const contactPageStyles = [
|
|
153
|
-
|
|
110
|
+
compiledStyle(`
|
|
154
111
|
:host { display: block; }
|
|
155
112
|
h1 { font-family: var(--font-serif); font-size: 2.4rem; letter-spacing: -0.015em; margin: 0.75rem 0 0.5rem; font-weight: 700; }
|
|
156
113
|
.sub { color: var(--ink-2); line-height: 1.6; max-width: 52ch; margin: 0 0 1.75rem; }
|