@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
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* app-shell — compiled layout island (v0.44, ADR-0143).
|
|
3
|
-
*
|
|
4
|
-
* The server entry renders this class around every page
|
|
5
|
-
* (appShell: { tagName, import, props } in vite.config.ts) and injects the
|
|
6
|
-
* page host before the closing tag; the static <slot> projects it. The shell
|
|
7
|
-
* is also a 'load' island: the compiled style scope applies `static styles`
|
|
8
|
-
* when the element activates client-side (the serializer never inlines
|
|
9
|
-
* styles into DSD), so the shell chrome is styled as soon as it hydrates.
|
|
10
|
-
*
|
|
11
|
-
* 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).
|
|
14
|
-
*/
|
|
15
|
-
import { defineIslandConfig } from '@openelement/router';
|
|
16
|
-
import { element, OpenElement, property } from '@openelement/element';
|
|
17
|
-
import { shellStyles } from '../components/page-styles.ts';
|
|
18
|
-
|
|
19
|
-
export const openElement = defineIslandConfig({ hydrate: 'load', ssr: true, dsd: true });
|
|
20
|
-
|
|
21
|
-
@element('app-shell', { root: 'shadow-open' })
|
|
22
|
-
export default class AppShell extends OpenElement {
|
|
23
|
-
static override styles = shellStyles;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Filled from appShell.props in vite.config.ts at render time.
|
|
27
|
-
* Attribute-backed (site-name) so the SSR'd value survives the client claim:
|
|
28
|
-
* attribute: false properties reset to their compiled default on claim and
|
|
29
|
-
* the drift check would fail closed.
|
|
30
|
-
*/
|
|
31
|
-
@property({ reflect: false })
|
|
32
|
-
siteName = 'openElement';
|
|
33
|
-
|
|
34
|
-
render() {
|
|
35
|
-
return (
|
|
36
|
-
<div class='shell-body'>
|
|
37
|
-
<header data-open-layout='app-shell'>
|
|
38
|
-
<div class='bar'>
|
|
39
|
-
<a class='brand' href='/'>{this.siteName}</a>
|
|
40
|
-
<nav>
|
|
41
|
-
<a href='/'>Home</a>
|
|
42
|
-
<a href='/blog'>Blog</a>
|
|
43
|
-
</nav>
|
|
44
|
-
</div>
|
|
45
|
-
</header>
|
|
46
|
-
<main>
|
|
47
|
-
<slot></slot>
|
|
48
|
-
</main>
|
|
49
|
-
<footer>
|
|
50
|
-
<div class='foot'>
|
|
51
|
-
<span>Generated by @openelement/create.</span>
|
|
52
|
-
<a href='https://github.com/open-element/openelement'>GitHub</a>
|
|
53
|
-
</div>
|
|
54
|
-
</footer>
|
|
55
|
-
</div>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* only-ticker — client-only island (v0.44 compiled, ADR-0143).
|
|
3
|
-
*
|
|
4
|
-
* hydrate: 'only' with ssr: false renders nothing on the server; the client
|
|
5
|
-
* entry creates the DOM fresh from the compiled Part Program and binds the
|
|
6
|
-
* tick event Part. Each hydrated island gets its own compiled property state,
|
|
7
|
-
* so multiple tickers on one page never share state.
|
|
8
|
-
*/
|
|
9
|
-
import { defineIslandConfig } from '@openelement/router';
|
|
10
|
-
import { element, OpenElement, property } from '@openelement/element';
|
|
11
|
-
import { tickerStyles } from '../components/page-styles.ts';
|
|
12
|
-
|
|
13
|
-
export const openElement = defineIslandConfig({ hydrate: 'only', ssr: false, dsd: false });
|
|
14
|
-
|
|
15
|
-
@element('only-ticker', { root: 'shadow-open' })
|
|
16
|
-
export default class OnlyTicker extends OpenElement {
|
|
17
|
-
static override styles = tickerStyles;
|
|
18
|
-
|
|
19
|
-
@property({ reflect: false, attribute: false })
|
|
20
|
-
tick = 0;
|
|
21
|
-
|
|
22
|
-
bump(): void {
|
|
23
|
-
this.tick++;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
render() {
|
|
27
|
-
return (
|
|
28
|
-
<div class='ticker-row'>
|
|
29
|
-
<span id='tick'>{this.tick}</span>
|
|
30
|
-
<button type='button' onClick={this.bump}>tick</button>
|
|
31
|
-
</div>
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/** Static blog index (default renderIntent mode 'static'). */
|
|
2
|
-
import { definePage } from '@openelement/router';
|
|
3
|
-
import BlogIndexPage from '../../components/page-blog-index.tsx';
|
|
4
|
-
|
|
5
|
-
export default definePage(BlogIndexPage, {
|
|
6
|
-
head: {
|
|
7
|
-
title: 'Blog — My openElement App',
|
|
8
|
-
description: 'Posts from app/routes/blog',
|
|
9
|
-
},
|
|
10
|
-
});
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/** Static blog post page (default renderIntent mode 'static'). */
|
|
2
|
-
import { definePage } from '@openelement/router';
|
|
3
|
-
import BlogWelcomePage from '../../components/page-blog-welcome.tsx';
|
|
4
|
-
|
|
5
|
-
export default definePage(BlogWelcomePage, {
|
|
6
|
-
head: { title: 'Welcome — My openElement App' },
|
|
7
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* /contact — a request-time route exercising the WC Application Loop: the
|
|
3
|
-
* plain HTML form works without JavaScript (422 echo / 303 PRG), and
|
|
4
|
-
* data-open-enhance morphs the page when JS is present. The props projector
|
|
5
|
-
* is the single deterministic seam mapping request scope onto the compiled
|
|
6
|
-
* page properties.
|
|
7
|
-
*/
|
|
8
|
-
import { definePage, fail, type OpenElementActionFailure, redirect } from '@openelement/router';
|
|
9
|
-
import ContactPage from '../components/page-contact.tsx';
|
|
10
|
-
|
|
11
|
-
interface ContactActionData {
|
|
12
|
-
error?: string;
|
|
13
|
-
email?: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function action(ctx: { formData: FormData }): OpenElementActionFailure<ContactActionData> {
|
|
17
|
-
const email = String(ctx.formData.get('email') ?? '').trim();
|
|
18
|
-
if (!/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(email)) {
|
|
19
|
-
return fail(422, { error: 'a valid email is required', email });
|
|
20
|
-
}
|
|
21
|
-
throw redirect(`/contact?subscribed=${encodeURIComponent(email)}`);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export default definePage(ContactPage, {
|
|
25
|
-
renderIntent: { mode: 'dynamic' },
|
|
26
|
-
head: { title: 'Contact — openElement' },
|
|
27
|
-
props({ request, actionData }) {
|
|
28
|
-
const subscribed = request ? new URL(request.url).searchParams.get('subscribed') : undefined;
|
|
29
|
-
const result = actionData as ContactActionData | undefined;
|
|
30
|
-
return {
|
|
31
|
-
email: result?.email ?? '',
|
|
32
|
-
errorText: result?.error ?? '',
|
|
33
|
-
subscribedText: subscribed ? `subscribed=${subscribed}` : '',
|
|
34
|
-
};
|
|
35
|
-
},
|
|
36
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* /freshness — static prerender proof route. The page is prerendered once at
|
|
3
|
-
* build time like any other static route; v0.44 ships no route-level cache
|
|
4
|
-
* revalidation semantics (ISR was removed, see issue #1217).
|
|
5
|
-
*/
|
|
6
|
-
import { definePage } from '@openelement/router';
|
|
7
|
-
import FreshnessPage from '../components/page-freshness.tsx';
|
|
8
|
-
|
|
9
|
-
export default definePage(FreshnessPage, {
|
|
10
|
-
head: {
|
|
11
|
-
title: 'Freshness proof',
|
|
12
|
-
description: 'Generated openElement static prerender route',
|
|
13
|
-
},
|
|
14
|
-
renderIntent: {
|
|
15
|
-
mode: 'static',
|
|
16
|
-
},
|
|
17
|
-
});
|
package/templates/deno.json.tmpl
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"imports": {
|
|
3
|
-
"@hono/vite-dev-server": "npm:@hono/vite-dev-server@^0.25.3",
|
|
4
|
-
"@openelement/router": "npm:@openelement/router@${v.router}",
|
|
5
|
-
"@openelement/router/vite": "npm:@openelement/router@${v.router}/vite",
|
|
6
|
-
"@openelement/router/nitro-mount": "npm:@openelement/router@${v.router}/nitro-mount",
|
|
7
|
-
"@openelement/element": "npm:@openelement/element@${v.element}",
|
|
8
|
-
"@openelement/element/build-utils": "npm:@openelement/element@${v.element}/build-utils",
|
|
9
|
-
"@openelement/element/jsx-dev-runtime": "npm:@openelement/element@${v.element}/jsx-dev-runtime",
|
|
10
|
-
"@openelement/element/jsx-runtime": "npm:@openelement/element@${v.element}/jsx-runtime",
|
|
11
|
-
"hono": "npm:hono@^4.12",
|
|
12
|
-
"vite": "npm:vite@${v.vite}"
|
|
13
|
-
},
|
|
14
|
-
"nodeModulesDir": "auto",
|
|
15
|
-
"minimumDependencyAge": 0,
|
|
16
|
-
"tasks": {
|
|
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",
|
|
19
|
-
"test": "deno test --config deno.json --permit-no-files",
|
|
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
|
-
"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",
|
|
22
|
-
"preview": "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 --mode=preview"
|
|
23
|
-
},
|
|
24
|
-
"compilerOptions": { "lib": ["ES2022", "DOM", "DOM.Iterable"], "jsx": "react-jsx", "jsxImportSource": "@openelement/element" }
|
|
25
|
-
}
|