@openelement/create 1.0.0-alpha.2 → 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 +36 -9
- package/package.json +15 -4
- package/src/cli.js +6 -3
- package/src/install-command.d.ts +33 -0
- package/src/install-command.js +36 -0
- package/src/template-builder.js +18 -0
- package/src/version.js +3 -3
- package/templates/README.tmpl +26 -6
- package/templates/app/components/page-blog-welcome.tsx.tmpl +1 -1
- package/templates/app/components/page-home.tsx.tmpl +1 -1
- package/templates/app/head.tsx.tmpl +42 -0
- package/templates/app/islands/app-shell.tsx.tmpl +14 -10
- package/templates/app/islands/my-counter.tsx.tmpl +1 -1
- package/templates/app/islands/only-ticker.tsx.tmpl +1 -1
- package/templates/app/styles/tokens.css +57 -0
- package/templates/deno.json.tmpl +1 -1
- package/templates/openelement.config.ts.tmpl +31 -0
- package/templates/vite.config.ts.tmpl +6 -32
package/README.md
CHANGED
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Project scaffolding CLI for openElement applications.
|
|
4
4
|
|
|
5
|
+
Docs and guides: <https://openelement.org>.
|
|
6
|
+
|
|
5
7
|
> 1.0 Alpha line: the supported creation entry for Element and Router. The
|
|
6
|
-
> published npm versions and dist-tags are
|
|
7
|
-
> `
|
|
8
|
-
>
|
|
8
|
+
> published npm versions and dist-tags are registry truth (query them with
|
|
9
|
+
> `npm view @openelement/create dist-tags`); `latest` stays on the stable 0.43
|
|
10
|
+
> line until a separately admitted stable release.
|
|
9
11
|
|
|
10
12
|
`@openelement/create` generates a new openElement project with the recommended
|
|
11
13
|
directory structure, Deno configuration, Vite setup, and starter pages.
|
|
@@ -13,18 +15,19 @@ directory structure, Deno configuration, Vite setup, and starter pages.
|
|
|
13
15
|
## Usage (1.0 Alpha)
|
|
14
16
|
|
|
15
17
|
```bash
|
|
16
|
-
deno run
|
|
18
|
+
deno run -A npm:@openelement/create@alpha my-app
|
|
17
19
|
cd my-app
|
|
18
20
|
deno task dev
|
|
19
21
|
```
|
|
20
22
|
|
|
21
23
|
The version `@alpha` resolves to is registered in
|
|
22
|
-
`
|
|
24
|
+
`the tracked release-state manifest` (currently `1.0.0-alpha.2`, a new baseline —
|
|
23
25
|
not a 0.x upgrade, with no migration path from 0.x). Pin that exact version
|
|
24
|
-
when reproducibility matters
|
|
26
|
+
when reproducibility matters (verify against the live registry with
|
|
27
|
+
`npm view @openelement/create dist-tags.alpha`):
|
|
25
28
|
|
|
26
29
|
```bash
|
|
27
|
-
deno run
|
|
30
|
+
deno run -A npm:@openelement/create@1.0.0-alpha.2 my-app
|
|
28
31
|
```
|
|
29
32
|
|
|
30
33
|
`--minimum-dependency-age 0` is needed because Deno's default
|
|
@@ -33,6 +36,22 @@ minimumDependencyAge (~24h) refuses packages published within the last day.
|
|
|
33
36
|
The generated starter pins the exact `@openelement/*` versions it was built
|
|
34
37
|
from in its `deno.json` import map.
|
|
35
38
|
|
|
39
|
+
The canonical install command is exported from `@openelement/create/install-command` (one builder, every documented copy derives from it).
|
|
40
|
+
|
|
41
|
+
## Do not run the bin under Node (`npx`)
|
|
42
|
+
|
|
43
|
+
> **Use the bare-flag create command documented above. Do not use
|
|
44
|
+
> `npx @openelement/create` / `npx create-openelement`.** The CLI is a Deno
|
|
45
|
+
> program: it is written against the Deno API, and its `bin` entries and
|
|
46
|
+
> shebang (`#!/usr/bin/env -S deno run --allow-read --allow-write`) both assume
|
|
47
|
+
> a Deno host. Under a plain Node host the bin dies at startup with
|
|
48
|
+
> `ReferenceError: Deno is not defined`.
|
|
49
|
+
>
|
|
50
|
+
> A Node-executable entry point is a deferred roadmap item (portable-host
|
|
51
|
+
> tooling, [#1387](https://github.com/open-element/openelement/issues/1387)).
|
|
52
|
+
> Until it lands, the bare-flag create form is the
|
|
53
|
+
> supported install path.
|
|
54
|
+
|
|
36
55
|
## Stable 0.43 (maintenance line)
|
|
37
56
|
|
|
38
57
|
The stable 0.43 line is still published, but it is not the Alpha install path.
|
|
@@ -40,7 +59,7 @@ A versionless install resolves the npm `latest` dist-tag to it; pin the line
|
|
|
40
59
|
explicitly instead:
|
|
41
60
|
|
|
42
61
|
```bash
|
|
43
|
-
deno run
|
|
62
|
+
deno run -A npm:@openelement/create@0.43 my-app
|
|
44
63
|
```
|
|
45
64
|
|
|
46
65
|
## Requirements
|
|
@@ -54,7 +73,15 @@ claimed or tested.
|
|
|
54
73
|
## What It Creates
|
|
55
74
|
|
|
56
75
|
- `deno.json` - starter authoring imports and build tasks
|
|
57
|
-
- `vite.config.ts` - Vite build configuration
|
|
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.
|
|
58
85
|
- `app/` - application directory with starter pages and islands
|
|
59
86
|
- `app/routes/blog/` - the sample blog as compiled page routes (`index` list
|
|
60
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
|
+
"version": "1.0.0-alpha.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/cli.js",
|
|
6
6
|
"types": "./src/cli.d.ts",
|
|
@@ -9,6 +9,11 @@
|
|
|
9
9
|
"types": "./src/cli.d.ts",
|
|
10
10
|
"import": "./src/cli.js",
|
|
11
11
|
"default": "./src/cli.js"
|
|
12
|
+
},
|
|
13
|
+
"./install-command": {
|
|
14
|
+
"types": "./src/install-command.d.ts",
|
|
15
|
+
"import": "./src/install-command.js",
|
|
16
|
+
"default": "./src/install-command.js"
|
|
12
17
|
}
|
|
13
18
|
},
|
|
14
19
|
"repository": {
|
|
@@ -22,9 +27,15 @@
|
|
|
22
27
|
"keywords": [
|
|
23
28
|
"openelement",
|
|
24
29
|
"web-components",
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
30
|
+
"scaffolding",
|
|
31
|
+
"generator",
|
|
32
|
+
"starter"
|
|
33
|
+
],
|
|
34
|
+
"engines": {
|
|
35
|
+
"deno": ">=2.9"
|
|
36
|
+
},
|
|
37
|
+
"sideEffects": [
|
|
38
|
+
"./src/cli.js"
|
|
28
39
|
],
|
|
29
40
|
"bin": {
|
|
30
41
|
"openelement-create": "./src/cli.js",
|
package/src/cli.js
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* @openelement/create - Minimal project scaffold for openElement framework.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* (
|
|
5
|
+
* The install command this CLI documents is built by ./install-command.ts
|
|
6
|
+
* (#1414): usage output, the guides and the homepage all render that one
|
|
7
|
+
* string, so the documented command cannot drift from the shipped flags.
|
|
7
8
|
*
|
|
8
9
|
* openElement Architecture: Keep It Simple, Stupid.
|
|
9
10
|
* One template, zero prompts, instant start.
|
|
@@ -11,6 +12,7 @@
|
|
|
11
12
|
* L9: every failure mode exits 1 with one actionable message — never a
|
|
12
13
|
* runtime stack trace.
|
|
13
14
|
*/ import { buildTemplates, resolveVersions, validateProjectName } from './template-builder.js';
|
|
15
|
+
import { createInstallCommand } from './install-command.js';
|
|
14
16
|
function errorMessage(error) {
|
|
15
17
|
return error instanceof Error ? error.message : String(error);
|
|
16
18
|
}
|
|
@@ -30,7 +32,8 @@ function dirnameOf(path) {
|
|
|
30
32
|
async function main() {
|
|
31
33
|
const name = Deno.args[0];
|
|
32
34
|
if (!name || name === '--help' || name === '-h') {
|
|
33
|
-
console.log(
|
|
35
|
+
console.log(`Usage (Alpha): ${createInstallCommand()}`);
|
|
36
|
+
console.log('(a versionless install resolves the stable 0.43 line)');
|
|
34
37
|
Deno.exit(name ? 0 : 1);
|
|
35
38
|
}
|
|
36
39
|
const invalid = validateProjectName(name);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The canonical install command — the ONE source every documented copy of it
|
|
3
|
+
* derives from (#1414 item 5).
|
|
4
|
+
*
|
|
5
|
+
* The command is data about this CLI, so it lives beside the CLI: `cli.ts`
|
|
6
|
+
* prints it in its usage output, the site's documentation generator inlines it
|
|
7
|
+
* into the guides and the homepage, and the install-command gate
|
|
8
|
+
* (the site's install-command generator --check) fails when any curated copy
|
|
9
|
+
* in the repository differs from this string. There is no second spelling to
|
|
10
|
+
* drift.
|
|
11
|
+
*
|
|
12
|
+
* This module is deliberately side-effect free (no top-level CLI execution, no
|
|
13
|
+
* Deno APIs): it is imported by the site build as well as by the CLI itself.
|
|
14
|
+
*/ /** The npm specifier the generator is published under. */ export declare const CREATE_PACKAGE_SPECIFIER: 'npm:@openelement/create';
|
|
15
|
+
/** The dist-tag the documented install resolves; the exact version is registry truth. */ export declare const CREATE_INSTALL_TAG: 'alpha';
|
|
16
|
+
/**
|
|
17
|
+
* Deno permissions the bootstrap needs. Owner ruling 2026-09-21: the
|
|
18
|
+
* documented command uses bare `-A` — the consumer scaffolds their own
|
|
19
|
+
* project, and the scoped-permission form reads as noise (the same ruling
|
|
20
|
+
* narrowed the `check-no-allow-all` tripwire to an exact-line exemption for
|
|
21
|
+
* this command). `--minimum-dependency-age 0` is a functional footnote kept
|
|
22
|
+
* in prose where needed, not part of the documented shape.
|
|
23
|
+
*/ export declare const CREATE_INSTALL_PERMISSIONS: readonly string[];
|
|
24
|
+
/** Placeholder the usage text and the docs use in place of a project name. */ export declare const CREATE_PROJECT_PLACEHOLDER: '<project-name>';
|
|
25
|
+
/**
|
|
26
|
+
* Build the canonical install command for `projectName`.
|
|
27
|
+
*
|
|
28
|
+
* `projectName` defaults to the placeholder so callers that document the
|
|
29
|
+
* command shape (usage output) and callers that show a concrete example share
|
|
30
|
+
* one builder and therefore one flag list.
|
|
31
|
+
*/ export declare function createInstallCommand(projectName?: string, options?: {
|
|
32
|
+
tag?: string;
|
|
33
|
+
}): string;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The canonical install command — the ONE source every documented copy of it
|
|
3
|
+
* derives from (#1414 item 5).
|
|
4
|
+
*
|
|
5
|
+
* The command is data about this CLI, so it lives beside the CLI: `cli.ts`
|
|
6
|
+
* prints it in its usage output, the site's documentation generator inlines it
|
|
7
|
+
* into the guides and the homepage, and the install-command gate
|
|
8
|
+
* (the site's install-command generator --check) fails when any curated copy
|
|
9
|
+
* in the repository differs from this string. There is no second spelling to
|
|
10
|
+
* drift.
|
|
11
|
+
*
|
|
12
|
+
* This module is deliberately side-effect free (no top-level CLI execution, no
|
|
13
|
+
* Deno APIs): it is imported by the site build as well as by the CLI itself.
|
|
14
|
+
*/ /** The npm specifier the generator is published under. */ export const CREATE_PACKAGE_SPECIFIER = 'npm:@openelement/create';
|
|
15
|
+
/** The dist-tag the documented install resolves; the exact version is registry truth. */ export const CREATE_INSTALL_TAG = 'alpha';
|
|
16
|
+
/**
|
|
17
|
+
* Deno permissions the bootstrap needs. Owner ruling 2026-09-21: the
|
|
18
|
+
* documented command uses bare `-A` — the consumer scaffolds their own
|
|
19
|
+
* project, and the scoped-permission form reads as noise (the same ruling
|
|
20
|
+
* narrowed the `check-no-allow-all` tripwire to an exact-line exemption for
|
|
21
|
+
* this command). `--minimum-dependency-age 0` is a functional footnote kept
|
|
22
|
+
* in prose where needed, not part of the documented shape.
|
|
23
|
+
*/ export const CREATE_INSTALL_PERMISSIONS = [
|
|
24
|
+
String.fromCharCode(45, 65)
|
|
25
|
+
];
|
|
26
|
+
/** Placeholder the usage text and the docs use in place of a project name. */ export const CREATE_PROJECT_PLACEHOLDER = '<project-name>';
|
|
27
|
+
/**
|
|
28
|
+
* Build the canonical install command for `projectName`.
|
|
29
|
+
*
|
|
30
|
+
* `projectName` defaults to the placeholder so callers that document the
|
|
31
|
+
* command shape (usage output) and callers that show a concrete example share
|
|
32
|
+
* one builder and therefore one flag list.
|
|
33
|
+
*/ export function createInstallCommand(projectName = CREATE_PROJECT_PLACEHOLDER, options = {}) {
|
|
34
|
+
const tag = options.tag ?? CREATE_INSTALL_TAG;
|
|
35
|
+
return `deno run ${CREATE_INSTALL_PERMISSIONS.join(' ')} ${CREATE_PACKAGE_SPECIFIER}@${tag} ${projectName}`;
|
|
36
|
+
}
|
package/src/template-builder.js
CHANGED
|
@@ -78,6 +78,24 @@ const TEMPLATE_FILES = [
|
|
|
78
78
|
'vite.config.ts.tmpl',
|
|
79
79
|
'vite.config.ts'
|
|
80
80
|
],
|
|
81
|
+
// #1411: framework options live in openelement.config.ts; the starter ships
|
|
82
|
+
// it near-empty, so every option comes from a file convention until the user
|
|
83
|
+
// overrides one.
|
|
84
|
+
[
|
|
85
|
+
'openelement.config.ts.tmpl',
|
|
86
|
+
'openelement.config.ts'
|
|
87
|
+
],
|
|
88
|
+
[
|
|
89
|
+
'app/styles/tokens.css',
|
|
90
|
+
'app/styles/tokens.css'
|
|
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
|
+
],
|
|
81
99
|
[
|
|
82
100
|
'app/islands/app-shell.tsx.tmpl',
|
|
83
101
|
'app/islands/app-shell.tsx'
|
package/src/version.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/** The published CLI version, embedded so packed npm installs are self-contained. */ export const CREATE_VERSION = '1.0.0-alpha.
|
|
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
|
|
5
|
-
* installs are self-contained);
|
|
6
|
-
* canonical
|
|
5
|
+
* installs are self-contained); the repository's Vite-pin check anchors this
|
|
6
|
+
* copy to the canonical dev pin.
|
|
7
7
|
*/ export const VITE_STARTER_PIN = '8.0.16';
|
package/templates/README.tmpl
CHANGED
|
@@ -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 `
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
page
|
|
17
|
-
|
|
18
|
-
|
|
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
|
|
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
|
|
@@ -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
|
+
];
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* app-shell — compiled layout island
|
|
2
|
+
* app-shell — compiled layout island.
|
|
3
3
|
*
|
|
4
|
-
* The server entry renders this class around every page
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
4
|
+
* The server entry renders this class around every page, registered by the
|
|
5
|
+
* `app/islands/app-shell.tsx` file convention; `openelement.config.ts`
|
|
6
|
+
* overrides it with `appShell: { import, props }`. The entry injects the page
|
|
7
|
+
* host before the closing tag and the static <slot> projects it. Deleting
|
|
8
|
+
* this file is supported: pages still render, just without the shell chrome.
|
|
9
|
+
* The shell is also a 'load' island: the compiled style scope applies
|
|
10
|
+
* `static styles` when the element activates client-side (the serializer
|
|
11
|
+
* never inlines styles into DSD), so the shell chrome is styled as soon as
|
|
12
|
+
* it hydrates.
|
|
10
13
|
*
|
|
11
14
|
* The compiler grammar v1 has no data-driven per-item attribute slots, so the
|
|
12
|
-
* header nav is static authoring here — edit the links below directly
|
|
13
|
-
* (the vite.config content.nav headerNav indirection of 0.43 is gone).
|
|
15
|
+
* header nav is static authoring here — edit the links below directly.
|
|
14
16
|
*/
|
|
15
17
|
import { defineIslandConfig } from '@openelement/router';
|
|
16
18
|
import { element, OpenElement, property } from '@openelement/element';
|
|
@@ -23,7 +25,9 @@ export default class AppShell extends OpenElement {
|
|
|
23
25
|
static override styles = shellStyles;
|
|
24
26
|
|
|
25
27
|
/**
|
|
26
|
-
* Filled from appShell.props
|
|
28
|
+
* Filled from `appShell.props` at render time; a convention app-shell
|
|
29
|
+
* carries no props, so set them in openelement.config.ts to change this
|
|
30
|
+
* (appShell: { import: './app/islands/app-shell.tsx', props: { siteName } }).
|
|
27
31
|
* Attribute-backed (site-name) so the SSR'd value survives the client claim:
|
|
28
32
|
* attribute: false properties reset to their compiled default on claim and
|
|
29
33
|
* the drift check would fail closed.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* my-counter — minimal counter island (
|
|
2
|
+
* my-counter — minimal counter island (compiled).
|
|
3
3
|
*
|
|
4
4
|
* Hydrates on idle; the buttons increment/decrement through the compiled
|
|
5
5
|
* event Parts and the count renders through the compiled text Part. The
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* only-ticker — client-only island (
|
|
2
|
+
* only-ticker — client-only island (compiled).
|
|
3
3
|
*
|
|
4
4
|
* hydrate: 'only' with ssr: false renders nothing on the server; the client
|
|
5
5
|
* entry creates the DOM fresh from the compiled Part Program and binds the
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/* Design tokens + the document baseline (openElement starter).
|
|
2
|
+
*
|
|
3
|
+
* Convention, not configuration: `openelement.config.ts` inlines this file
|
|
4
|
+
* into every rendered document's <head> as <style data-oe-tokens>. Override
|
|
5
|
+
* the path with `styles: { tokens: '...' }` there; delete the file and the
|
|
6
|
+
* pages render unstyled but functional.
|
|
7
|
+
*
|
|
8
|
+
* Styling ownership: only true globals (design tokens, body baseline) live
|
|
9
|
+
* here. Each page element carries its own rules in `static styles`
|
|
10
|
+
* (`app/components/page-styles.ts`) — the server inlines them into the SSR
|
|
11
|
+
* output as a @scope(<page-tag>) style block for light roots. Islands carry
|
|
12
|
+
* their own `static styles` too.
|
|
13
|
+
*
|
|
14
|
+
* `--brand` must stay aligned with the ui package tokens (`--violet-6` in a
|
|
15
|
+
* consumer-owned design-system stylesheet).
|
|
16
|
+
*/
|
|
17
|
+
:root {
|
|
18
|
+
--paper: #faf9f6;
|
|
19
|
+
--ink: #1c1b17;
|
|
20
|
+
--ink-2: #5b594f;
|
|
21
|
+
--line: #e5e2d8;
|
|
22
|
+
--gray-0: #f8f9fa;
|
|
23
|
+
--gray-1: #f1f3f5;
|
|
24
|
+
--gray-3: #dee2e6;
|
|
25
|
+
--gray-5: #adb5bd;
|
|
26
|
+
--gray-7: #495057;
|
|
27
|
+
--gray-9: #212529;
|
|
28
|
+
--brand: #8262db;
|
|
29
|
+
--brand-2: #4f8ef7;
|
|
30
|
+
--size-1: 4px;
|
|
31
|
+
--size-2: 8px;
|
|
32
|
+
--size-3: 12px;
|
|
33
|
+
--size-4: 16px;
|
|
34
|
+
--border-size-1: 1px;
|
|
35
|
+
--radius-2: 8px;
|
|
36
|
+
--radius-3: 14px;
|
|
37
|
+
--font-sans: system-ui, -apple-system, sans-serif;
|
|
38
|
+
--font-serif: ui-serif, Georgia, 'Times New Roman', serif;
|
|
39
|
+
--font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
40
|
+
--font-size-0: 0.875rem;
|
|
41
|
+
--font-weight-5: 500;
|
|
42
|
+
--shadow-1: 0 1px 3px 0 rgb(0 0 0 / 0.08);
|
|
43
|
+
--shadow-2: 0 10px 28px rgb(80 70 160 / 0.12);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
body {
|
|
47
|
+
margin: 0;
|
|
48
|
+
background: var(--paper);
|
|
49
|
+
color: var(--ink);
|
|
50
|
+
font-family: var(--font-sans);
|
|
51
|
+
-webkit-font-smoothing: antialiased;
|
|
52
|
+
-moz-osx-font-smoothing: grayscale;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
::selection {
|
|
56
|
+
background: #8262db2e;
|
|
57
|
+
}
|
package/templates/deno.json.tmpl
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"minimumDependencyAge": 0,
|
|
16
16
|
"tasks": {
|
|
17
17
|
"dev": "deno run --config deno.json --allow-read --allow-write --allow-env --allow-net --allow-run --allow-sys --allow-ffi npm:vite@${v.vite}",
|
|
18
|
-
"check": "deno check --config deno.json app/ vite.config.ts",
|
|
18
|
+
"check": "deno check --config deno.json app/ vite.config.ts openelement.config.ts",
|
|
19
19
|
"test": "deno test --config deno.json --permit-no-files",
|
|
20
20
|
"build": "deno run --config deno.json --allow-read --allow-write --allow-net --allow-env --allow-ffi --allow-sys --allow-run npm:@openelement/router@${v.router}/cli/build",
|
|
21
21
|
"start": "deno run --config deno.json --allow-read --allow-write --allow-net --allow-env --allow-ffi --allow-sys --allow-run npm:@openelement/router@${v.router}/cli/start",
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// openelement.config.ts — framework options have exactly one home: this file.
|
|
2
|
+
//
|
|
3
|
+
// Every option below is OPTIONAL. With an empty object, options come from the
|
|
4
|
+
// file conventions:
|
|
5
|
+
// - design tokens: app/styles/tokens.css (inlined into every document <head>)
|
|
6
|
+
// - app shell: app/islands/app-shell.tsx (auto-registered; the file is
|
|
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)
|
|
11
|
+
// - site title: the "name" field of package.json
|
|
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
|
+
//
|
|
18
|
+
// Passing framework options inline to openElement() while this file carries
|
|
19
|
+
// options is a hard error: framework options cannot have two homes. Unknown
|
|
20
|
+
// keys are rejected with the accepted-key list.
|
|
21
|
+
import { defineConfig } from '@openelement/router';
|
|
22
|
+
|
|
23
|
+
export default defineConfig({
|
|
24
|
+
head: {
|
|
25
|
+
// Titles default to the package.json "name"; this overrides the document
|
|
26
|
+
// title fallback while page routes keep their own `head: { title }`.
|
|
27
|
+
title: 'My openElement App',
|
|
28
|
+
description: 'An openElement starter application.',
|
|
29
|
+
favicon: '/openelement-mark.svg',
|
|
30
|
+
},
|
|
31
|
+
});
|
|
@@ -1,37 +1,11 @@
|
|
|
1
1
|
import { openElement } from '@openelement/router/vite';
|
|
2
2
|
import { defineConfig } from 'vite';
|
|
3
3
|
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
// Styling ownership: only true globals (design tokens, body baseline) live
|
|
9
|
-
// here in headFragments. Each page element carries its own rules in
|
|
10
|
-
// `static styles` (app/components/page-styles.ts) — the server inlines them
|
|
11
|
-
// into the SSR output as a @scope(<page-tag>) style block for light roots.
|
|
12
|
-
// Islands carry their own `static styles` too.
|
|
13
|
-
const globalStyle =
|
|
14
|
-
'<style>:root{--paper:#faf9f6;--ink:#1c1b17;--ink-2:#5b594f;--line:#e5e2d8;--gray-0:#f8f9fa;--gray-1:#f1f3f5;--gray-3:#dee2e6;--gray-5:#adb5bd;--gray-7:#495057;--gray-9:#212529;--brand:#8262db;--brand-2:#4f8ef7;--size-1:4px;--size-2:8px;--size-3:12px;--size-4:16px;--border-size-1:1px;--radius-2:8px;--radius-3:14px;--font-sans:system-ui,-apple-system,sans-serif;--font-serif:ui-serif,Georgia,"Times New Roman",serif;--font-mono:ui-monospace,SFMono-Regular,Menlo,monospace;--font-size-0:0.875rem;--font-weight-5:500;--shadow-1:0 1px 3px 0 rgb(0 0 0 / 0.08);--shadow-2:0 10px 28px rgb(80 70 160 / 0.12)}' +
|
|
15
|
-
'body{margin:0;background:var(--paper);color:var(--ink);font-family:var(--font-sans);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}' +
|
|
16
|
-
'::selection{background:#8262db2e}' +
|
|
17
|
-
'</style>';
|
|
18
|
-
|
|
4
|
+
// Vite configuration only. Framework options live in openelement.config.ts —
|
|
5
|
+
// the plugin reads that file itself, so this stays `plugins: [openElement()]`.
|
|
6
|
+
// The JSX transform is owned by the plugin's compiler pass (TSX → Part
|
|
7
|
+
// Program); nothing JSX-related needs configuring here.
|
|
19
8
|
export default defineConfig({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
html: { title: 'My openElement App' },
|
|
23
|
-
appShell: {
|
|
24
|
-
tagName: 'app-shell',
|
|
25
|
-
import: './app/islands/app-shell.tsx',
|
|
26
|
-
props: {
|
|
27
|
-
siteName: 'My openElement App',
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
inject: {
|
|
31
|
-
headFragments: [
|
|
32
|
-
globalStyle,
|
|
33
|
-
],
|
|
34
|
-
},
|
|
35
|
-
}),
|
|
36
|
-
],
|
|
9
|
+
base: '/',
|
|
10
|
+
plugins: [...openElement()],
|
|
37
11
|
});
|