@openelement/create 1.0.0-alpha.3 → 1.0.0-alpha.4

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 CHANGED
@@ -73,7 +73,15 @@ claimed or tested.
73
73
  ## What It Creates
74
74
 
75
75
  - `deno.json` - starter authoring imports and build tasks
76
- - `vite.config.ts` - Vite build configuration with the openElement plugin
76
+ - `vite.config.ts` - Vite build configuration; the plugin call is plain
77
+ `openElement()`, because framework options have exactly one home:
78
+ - `openelement.config.ts` - the framework options. It is OPTIONAL and nearly
79
+ empty by default; every option it omits comes from a file convention —
80
+ design tokens from `app/styles/tokens.css`, the app shell from
81
+ `app/islands/app-shell.tsx`, structural document-head content from
82
+ `app/head.tsx`, the site title from `package.json`. Passing framework
83
+ options inline to `openElement()` while this file carries options is a hard
84
+ error, and an unknown key fails the build with the accepted-key list.
77
85
  - `app/` - application directory with starter pages and islands
78
86
  - `app/routes/blog/` - the sample blog as compiled page routes (`index` list
79
87
  and `welcome` post), prerendered at build time
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openelement/create",
3
- "version": "1.0.0-alpha.3",
3
+ "version": "1.0.0-alpha.4",
4
4
  "type": "module",
5
5
  "main": "./src/cli.js",
6
6
  "types": "./src/cli.d.ts",
@@ -89,6 +89,13 @@ const TEMPLATE_FILES = [
89
89
  'app/styles/tokens.css',
90
90
  'app/styles/tokens.css'
91
91
  ],
92
+ // alpha.4: the structural document-head convention. The config file carries
93
+ // the structured `head` channel (title/description/favicon/scripts); this
94
+ // module carries what a URL list cannot express (meta tags, preloads).
95
+ [
96
+ 'app/head.tsx.tmpl',
97
+ 'app/head.tsx'
98
+ ],
92
99
  [
93
100
  'app/islands/app-shell.tsx.tmpl',
94
101
  'app/islands/app-shell.tsx'
package/src/version.js CHANGED
@@ -1,4 +1,4 @@
1
- /** The published CLI version, embedded so packed npm installs are self-contained. */ export const CREATE_VERSION = '1.0.0-alpha.3';
1
+ /** The published CLI version, embedded so packed npm installs are self-contained. */ export const CREATE_VERSION = '1.0.0-alpha.4';
2
2
  /**
3
3
  * The Vite dev release stamped into the generated starter's import map and
4
4
  * dev task. Embedded for the same reason as CREATE_VERSION (packed npm
@@ -10,12 +10,32 @@ versions it was generated from (`${v.element}`) in `deno.json`; update both
10
10
  there when moving to a new release.
11
11
 
12
12
  Styling ownership is split three ways. Global design tokens and the document
13
- baseline (`body`, `::selection`) live in `vite.config.ts`
14
- (`inject.headFragments`). Pages use light roots and own their rules in
15
- `static styles` (`app/components/page-styles.ts`): the server inlines each
16
- page's sheets into the SSR output as a `@scope(<page-tag>)` style block, so
17
- pages are fully styled with zero client JavaScript. The shell and the islands
18
- hydrate in the browser and carry their own `static styles`.
13
+ baseline (`body`, `::selection`) live in `app/styles/tokens.css` — the file
14
+ convention the build inlines into every document `<head>`. Pages use light
15
+ roots and own their rules in `static styles`
16
+ (`app/components/page-styles.ts`): the server inlines each page's sheets into
17
+ the SSR output as a `@scope(<page-tag>)` style block, so pages are fully styled
18
+ with zero client JavaScript. The shell and the islands hydrate in the browser
19
+ and carry their own `static styles`.
20
+
21
+ ## Where options live
22
+
23
+ Framework options have exactly one home: `openelement.config.ts`. It is
24
+ optional and nearly empty — every option it omits comes from a file
25
+ convention:
26
+
27
+ | Option | Convention |
28
+ | --- | --- |
29
+ | design tokens | `app/styles/tokens.css` |
30
+ | app shell | `app/islands/app-shell.tsx` (deletable) |
31
+ | document head content | `app/head.tsx` (meta tags, preloads, inline CSS) |
32
+ | site title | the `name` field of `package.json` |
33
+
34
+ Passing framework options inline to `openElement()` while the config file
35
+ carries options is a hard error, and an unknown key fails the build with the
36
+ accepted-key list. `vite.config.ts` stays Vite-only: `plugins: [...openElement()]`.
37
+ The conventions follow the `dirs` block, so moving the three roots under
38
+ `src/` moves the token, shell and head files with them.
19
39
 
20
40
  ## Tasks
21
41
 
@@ -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 from vite.config.ts</li>
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>
@@ -0,0 +1,42 @@
1
+ /**
2
+ * app/head.tsx — the starter's structural document-head content.
3
+ *
4
+ * Everything here is DATA: the framework validates attribute names and URL
5
+ * values, escapes every attribute, and serializes the tags into the document
6
+ * <head>. The array is emitted in the order written, so this file is the head
7
+ * order. Delete the file and the starter still builds — it is a convention, not
8
+ * a requirement.
9
+ *
10
+ * Entries take one of three shapes:
11
+ * { meta: { name, content } } one <meta> tag
12
+ * { link: { rel, href, ... } } one <link> tag (rel and href are required)
13
+ * { style: 'css text' } one inline <style> block
14
+ *
15
+ * The module is compiled by the build, so it can import CSS by URL
16
+ * (`import css from './site.css?raw'`) and pull constants from local modules.
17
+ * It must not use host APIs (no Deno, no Node): its output is a build artifact,
18
+ * so a runtime read would make the document depend on the build machine.
19
+ *
20
+ * `head` in openelement.config.ts already covers the title, description,
21
+ * favicon and the og:/twitter: pairs; `head.scripts` / `head.stylesheets`
22
+ * cover external scripts and stylesheets. This file is for what neither can
23
+ * express — here, a resource preload. Per-page meaning (title, description,
24
+ * og:title, canonical) is declared by each route module's `head`, which
25
+ * resolves at render time and wins for crawlers.
26
+ */
27
+ export default [
28
+ // The brand mark is used above the fold on the starter home page, so it is
29
+ // preloaded. `crossorigin` needs an explicit value when the resource is
30
+ // fetched with CORS; an image preload without it is same-origin as authored.
31
+ {
32
+ link: {
33
+ rel: 'preload',
34
+ href: '/openelement-mark.svg',
35
+ as: 'image',
36
+ type: 'image/svg+xml',
37
+ },
38
+ },
39
+ // Declaring the color scheme the starter supports lets the browser pick the
40
+ // right native form/scrollbar palette before any CSS is parsed.
41
+ { meta: { name: 'color-scheme', content: 'dark light' } },
42
+ ];
@@ -12,8 +12,7 @@
12
12
  * it hydrates.
13
13
  *
14
14
  * The compiler grammar v1 has no data-driven per-item attribute slots, so the
15
- * header nav is static authoring here — edit the links below directly
16
- * (the vite.config content.nav headerNav indirection of 0.43 is gone).
15
+ * header nav is static authoring here — edit the links below directly.
17
16
  */
18
17
  import { defineIslandConfig } from '@openelement/router';
19
18
  import { element, OpenElement, property } from '@openelement/element';
@@ -5,8 +5,16 @@
5
5
  // - design tokens: app/styles/tokens.css (inlined into every document <head>)
6
6
  // - app shell: app/islands/app-shell.tsx (auto-registered; the file is
7
7
  // deletable and pages still render)
8
+ // - document head: app/head.tsx (structural head content: meta tags, font
9
+ // preloads, icons, inline CSS — the entries a URL list
10
+ // cannot express; `head` below covers the rest)
8
11
  // - site title: the "name" field of package.json
9
12
  //
13
+ // The conventions follow `dirs`: give the three roots a shared leading
14
+ // directory (src/routes, src/islands, src/components) and the tokens/app-shell/
15
+ // head conventions resolve under that same directory (src/styles/tokens.css,
16
+ // src/islands/app-shell.tsx, src/head.tsx).
17
+ //
10
18
  // Passing framework options inline to openElement() while this file carries
11
19
  // options is a hard error: framework options cannot have two homes. Unknown
12
20
  // keys are rejected with the accepted-key list.