@zenithbuild/core 0.1.0
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/.eslintignore +15 -0
- package/.gitattributes +2 -0
- package/.github/ISSUE_TEMPLATE/compiler-errors-for-invalid-state-declarations.md +25 -0
- package/.github/ISSUE_TEMPLATE/new_ticket.yaml +34 -0
- package/.github/pull_request_template.md +15 -0
- package/.github/workflows/discord-changelog.yml +141 -0
- package/.github/workflows/discord-notify.yml +242 -0
- package/.github/workflows/discord-version.yml +195 -0
- package/.prettierignore +13 -0
- package/.prettierrc +21 -0
- package/.zen.d.ts +15 -0
- package/LICENSE +21 -0
- package/README.md +55 -0
- package/app/components/Button.zen +46 -0
- package/app/components/Link.zen +11 -0
- package/app/favicon.ico +0 -0
- package/app/layouts/Main.zen +59 -0
- package/app/pages/about.zen +23 -0
- package/app/pages/blog/[id].zen +53 -0
- package/app/pages/blog/index.zen +32 -0
- package/app/pages/dynamic-dx.zen +712 -0
- package/app/pages/dynamic-primitives.zen +453 -0
- package/app/pages/index.zen +154 -0
- package/app/pages/navigation-demo.zen +229 -0
- package/app/pages/posts/[...slug].zen +61 -0
- package/app/pages/primitives-demo.zen +273 -0
- package/assets/logos/0E3B5DDD-605C-4839-BB2E-DFCA8ADC9604.PNG +0 -0
- package/assets/logos/760971E5-79A1-44F9-90B9-925DF30F4278.PNG +0 -0
- package/assets/logos/8A06ED80-9ED2-4689-BCBD-13B2E95EE8E4.JPG +0 -0
- package/assets/logos/C691FF58-ED13-4E8D-B6A3-02E835849340.PNG +0 -0
- package/assets/logos/C691FF58-ED13-4E8D-B6A3-02E835849340.svg +601 -0
- package/assets/logos/README.md +54 -0
- package/assets/logos/zen.icns +0 -0
- package/bun.lock +39 -0
- package/compiler/README.md +380 -0
- package/compiler/errors/compilerError.ts +24 -0
- package/compiler/finalize/finalizeOutput.ts +163 -0
- package/compiler/finalize/generateFinalBundle.ts +82 -0
- package/compiler/index.ts +44 -0
- package/compiler/ir/types.ts +83 -0
- package/compiler/legacy/binding.ts +254 -0
- package/compiler/legacy/bindings.ts +338 -0
- package/compiler/legacy/component-process.ts +1208 -0
- package/compiler/legacy/component.ts +301 -0
- package/compiler/legacy/event.ts +50 -0
- package/compiler/legacy/expression.ts +1149 -0
- package/compiler/legacy/mutation.ts +280 -0
- package/compiler/legacy/parse.ts +299 -0
- package/compiler/legacy/split.ts +608 -0
- package/compiler/legacy/types.ts +32 -0
- package/compiler/output/types.ts +34 -0
- package/compiler/parse/detectMapExpressions.ts +102 -0
- package/compiler/parse/parseScript.ts +22 -0
- package/compiler/parse/parseTemplate.ts +425 -0
- package/compiler/parse/parseZenFile.ts +66 -0
- package/compiler/parse/trackLoopContext.ts +82 -0
- package/compiler/runtime/dataExposure.ts +291 -0
- package/compiler/runtime/generateDOM.ts +144 -0
- package/compiler/runtime/generateHydrationBundle.ts +383 -0
- package/compiler/runtime/hydration.ts +309 -0
- package/compiler/runtime/navigation.ts +432 -0
- package/compiler/runtime/thinRuntime.ts +160 -0
- package/compiler/runtime/transformIR.ts +256 -0
- package/compiler/runtime/wrapExpression.ts +84 -0
- package/compiler/runtime/wrapExpressionWithLoop.ts +77 -0
- package/compiler/spa-build.ts +1000 -0
- package/compiler/test/validate-test.ts +104 -0
- package/compiler/transform/generateBindings.ts +47 -0
- package/compiler/transform/generateHTML.ts +28 -0
- package/compiler/transform/transformNode.ts +126 -0
- package/compiler/transform/transformTemplate.ts +38 -0
- package/compiler/validate/validateExpressions.ts +168 -0
- package/core/index.ts +135 -0
- package/core/lifecycle/index.ts +49 -0
- package/core/lifecycle/zen-mount.ts +182 -0
- package/core/lifecycle/zen-unmount.ts +88 -0
- package/core/reactivity/index.ts +54 -0
- package/core/reactivity/tracking.ts +167 -0
- package/core/reactivity/zen-batch.ts +57 -0
- package/core/reactivity/zen-effect.ts +139 -0
- package/core/reactivity/zen-memo.ts +146 -0
- package/core/reactivity/zen-ref.ts +52 -0
- package/core/reactivity/zen-signal.ts +121 -0
- package/core/reactivity/zen-state.ts +180 -0
- package/core/reactivity/zen-untrack.ts +44 -0
- package/docs/COMMENTS.md +111 -0
- package/docs/COMMITS.md +36 -0
- package/docs/CONTRIBUTING.md +116 -0
- package/docs/STYLEGUIDE.md +62 -0
- package/package.json +44 -0
- package/router/index.ts +76 -0
- package/router/manifest.ts +314 -0
- package/router/navigation/ZenLink.zen +231 -0
- package/router/navigation/index.ts +78 -0
- package/router/navigation/zen-link.ts +584 -0
- package/router/runtime.ts +458 -0
- package/router/types.ts +168 -0
- package/runtime/build.ts +17 -0
- package/runtime/serve.ts +93 -0
- package/scripts/webhook-proxy.ts +213 -0
- package/tsconfig.json +28 -0
package/.prettierrc
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"singleQuote": true,
|
|
3
|
+
"trailingComma": "es5",
|
|
4
|
+
"tabWidth": 2,
|
|
5
|
+
"semi": true,
|
|
6
|
+
"printWidth": 80,
|
|
7
|
+
"overrides": [
|
|
8
|
+
{
|
|
9
|
+
"files": "*.zen",
|
|
10
|
+
"options": {
|
|
11
|
+
"parser": "html"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"files": "*.ts",
|
|
16
|
+
"options": {
|
|
17
|
+
"parser": "typescript"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}
|
package/.zen.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Type definitions for .zen files
|
|
2
|
+
// This file tells the TypeScript linter that 'state' is a valid keyword in .zen files
|
|
3
|
+
|
|
4
|
+
declare global {
|
|
5
|
+
// State declarations are valid in .zen script tags
|
|
6
|
+
// The compiler processes these at compile time
|
|
7
|
+
const state: never; // Prevent accidental use in regular TypeScript files
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// Note: The 'state' keyword is processed by the Zenith compiler
|
|
11
|
+
// and transformed into runtime code. Linter errors for 'state' in .zen files
|
|
12
|
+
// are expected and can be ignored - the compiler handles them correctly.
|
|
13
|
+
|
|
14
|
+
export {};
|
|
15
|
+
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Judah Sullivan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
|
|
2
|
+
# Zenith Framework
|
|
3
|
+
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## README.md
|
|
7
|
+
|
|
8
|
+
### What is Zenith?
|
|
9
|
+
|
|
10
|
+
Zenith is an **HTML-first, web-native framework** focused on predictable rendering, persistent navigation state, and minimal JavaScript by default.
|
|
11
|
+
|
|
12
|
+
Zenith treats HTML as the source of truth. Behavior is inferred through static analysis rather than developer flags like `use client` or `client-only`.
|
|
13
|
+
|
|
14
|
+
The framework is currently **under active construction**. Core goals and constraints are intentionally defined early to avoid runtime complexity and hydration pitfalls seen in existing frameworks.
|
|
15
|
+
|
|
16
|
+
### Core Principles (Locked In)
|
|
17
|
+
|
|
18
|
+
* HTML-first authoring
|
|
19
|
+
* `.zenith` file format
|
|
20
|
+
* Optional `<script>` and `<style>` blocks
|
|
21
|
+
* No required `<template>` wrapper
|
|
22
|
+
* Automatic client/runtime detection
|
|
23
|
+
* Navigation lifecycle as a first-class primitive
|
|
24
|
+
* Persistent layouts across navigation
|
|
25
|
+
* VDOM used intentionally (not everywhere)
|
|
26
|
+
|
|
27
|
+
### What Zenith Is (Currently)
|
|
28
|
+
|
|
29
|
+
* A compiler that transforms `.zenith` files into optimized runtime modules
|
|
30
|
+
* A navigation-aware runtime with lifecycle hooks
|
|
31
|
+
* A layout + document ownership system
|
|
32
|
+
|
|
33
|
+
### What Zenith Is Not (Yet)
|
|
34
|
+
|
|
35
|
+
* A finished production framework
|
|
36
|
+
* A replacement for all React/Vue use-cases
|
|
37
|
+
* An SSR platform (planned, not finalized)
|
|
38
|
+
|
|
39
|
+
### High-Level Architecture
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
.zenith files
|
|
43
|
+
↓
|
|
44
|
+
Compiler (parse → analyze → compose → generate)
|
|
45
|
+
↓
|
|
46
|
+
Runtime (navigation + rendering)
|
|
47
|
+
↓
|
|
48
|
+
DOM
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Status
|
|
52
|
+
|
|
53
|
+
Zenith is in the **foundation phase**. APIs may change rapidly.
|
|
54
|
+
|
|
55
|
+
### [Contributing](./docs/CONTRIBUTING.md)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
type Props = {
|
|
3
|
+
onClick?: (count: number) => void
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
state count = 0
|
|
7
|
+
|
|
8
|
+
function handleClick() {
|
|
9
|
+
// Internal state mutation
|
|
10
|
+
count += 1
|
|
11
|
+
// Call parent callback prop if provided
|
|
12
|
+
if (onClick) {
|
|
13
|
+
onClick(count)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<style>
|
|
19
|
+
.btn {
|
|
20
|
+
padding: 8px 16px;
|
|
21
|
+
background: #007bff;
|
|
22
|
+
color: white;
|
|
23
|
+
border-radius: 4px;
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
border: none;
|
|
26
|
+
margin: 4px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.btn-clicked {
|
|
30
|
+
background: #0056b3;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.btn-large {
|
|
34
|
+
padding: 12px 24px;
|
|
35
|
+
font-size: 16px;
|
|
36
|
+
}
|
|
37
|
+
</style>
|
|
38
|
+
|
|
39
|
+
<button
|
|
40
|
+
class="btn"
|
|
41
|
+
:class="{ 'btn-clicked': count > 0, 'btn-large': count > 5 }"
|
|
42
|
+
onclick="handleClick"
|
|
43
|
+
>
|
|
44
|
+
Click Me { count }
|
|
45
|
+
</button>
|
|
46
|
+
|
package/app/favicon.ico
ADDED
|
Binary file
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<head>
|
|
3
|
+
<title>Zenith - Phase 3 Components</title>
|
|
4
|
+
</head>
|
|
5
|
+
<body>
|
|
6
|
+
<script>
|
|
7
|
+
type Props = {
|
|
8
|
+
title?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
state title = props.title || 'My App'
|
|
12
|
+
</script>
|
|
13
|
+
<style>
|
|
14
|
+
* {
|
|
15
|
+
box-sizing: border-box;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
body {
|
|
19
|
+
font-family: Arial, sans-serif;
|
|
20
|
+
margin: 0;
|
|
21
|
+
padding: 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.layout-header {
|
|
25
|
+
background: #f0f0f0;
|
|
26
|
+
padding: 16px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.layout-footer {
|
|
30
|
+
background: #f0f0f0;
|
|
31
|
+
padding: 16px;
|
|
32
|
+
margin-top: 20px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.layout-main {
|
|
36
|
+
min-height: calc(100vh - 120px);
|
|
37
|
+
width: 100%;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* Hide layout header/footer for pages that have their own full design */
|
|
41
|
+
.full-page ~ .layout-header,
|
|
42
|
+
.full-page ~ .layout-footer {
|
|
43
|
+
display: none;
|
|
44
|
+
}
|
|
45
|
+
</style>
|
|
46
|
+
|
|
47
|
+
<header class="layout-header">
|
|
48
|
+
<h1>{ title }</h1>
|
|
49
|
+
</header>
|
|
50
|
+
|
|
51
|
+
<main class="layout-main">
|
|
52
|
+
<Slot />
|
|
53
|
+
</main>
|
|
54
|
+
|
|
55
|
+
<footer class="layout-footer">Footer content here</footer>
|
|
56
|
+
</body>
|
|
57
|
+
|
|
58
|
+
</html>
|
|
59
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<Main title="About Us">
|
|
2
|
+
<div>
|
|
3
|
+
<h1>About Zenith</h1>
|
|
4
|
+
<p>Zenith is a modern web framework with file-based routing.</p>
|
|
5
|
+
|
|
6
|
+
<div style="margin: 20px 0; padding: 20px; border: 1px solid #ccc; border-radius: 8px;">
|
|
7
|
+
<h3>Route Information</h3>
|
|
8
|
+
<p>This page is rendered from <code>pages/about.zen</code></p>
|
|
9
|
+
<p>Current path: <code>/about</code></p>
|
|
10
|
+
</div>
|
|
11
|
+
|
|
12
|
+
<nav style="margin-top: 20px;">
|
|
13
|
+
<h3>Navigation</h3>
|
|
14
|
+
<ul style="list-style: none; padding: 0;">
|
|
15
|
+
<li><a href="/">Home</a></li>
|
|
16
|
+
<li><a href="/about">About (current)</a></li>
|
|
17
|
+
<li><a href="/blog">Blog</a></li>
|
|
18
|
+
<li><a href="/blog/123">Blog Post 123</a></li>
|
|
19
|
+
<li><a href="/posts/hello/world">Posts Catch-all</a></li>
|
|
20
|
+
</ul>
|
|
21
|
+
</nav>
|
|
22
|
+
</div>
|
|
23
|
+
</Main>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
// Access route params from the global route state
|
|
3
|
+
const route = window.__zenith_route || { params: {} };
|
|
4
|
+
const postId = route.params.id || 'unknown';
|
|
5
|
+
|
|
6
|
+
// Update the display when route changes
|
|
7
|
+
if (window.__zenith_router) {
|
|
8
|
+
window.__zenith_router.onRouteChange(function(newRoute) {
|
|
9
|
+
const idEl = document.getElementById('post-id');
|
|
10
|
+
if (idEl) {
|
|
11
|
+
idEl.textContent = newRoute.params.id || 'unknown';
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<Main title="Blog Post">
|
|
18
|
+
<div>
|
|
19
|
+
<h1>Blog Post</h1>
|
|
20
|
+
|
|
21
|
+
<div style="margin: 20px 0; padding: 20px; background: #e8f4f8; border-radius: 8px;">
|
|
22
|
+
<h2>Post ID: <span id="post-id" data-zen-bind="postId"></span></h2>
|
|
23
|
+
<p>This is a dynamic route page!</p>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
<div style="margin: 20px 0; padding: 20px; border: 1px solid #ccc; border-radius: 8px;">
|
|
27
|
+
<h3>Route Information</h3>
|
|
28
|
+
<p>This page is rendered from <code>pages/blog/[id].zen</code></p>
|
|
29
|
+
<p>Route pattern: <code>/blog/:id</code></p>
|
|
30
|
+
<p>The <code>id</code> parameter is extracted from the URL.</p>
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<div style="margin: 20px 0;">
|
|
34
|
+
<h3>Try Different IDs</h3>
|
|
35
|
+
<ul>
|
|
36
|
+
<li><a href="/blog/1">Post 1</a></li>
|
|
37
|
+
<li><a href="/blog/42">Post 42</a></li>
|
|
38
|
+
<li><a href="/blog/hello-world">Post hello-world</a></li>
|
|
39
|
+
<li><a href="/blog/my-awesome-post">Post my-awesome-post</a></li>
|
|
40
|
+
</ul>
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
<nav style="margin-top: 20px;">
|
|
44
|
+
<h3>Navigation</h3>
|
|
45
|
+
<ul style="list-style: none; padding: 0;">
|
|
46
|
+
<li><a href="/">Home</a></li>
|
|
47
|
+
<li><a href="/about">About</a></li>
|
|
48
|
+
<li><a href="/blog">Blog Index</a></li>
|
|
49
|
+
</ul>
|
|
50
|
+
</nav>
|
|
51
|
+
</div>
|
|
52
|
+
</Main>
|
|
53
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<Main title="Blog">
|
|
2
|
+
<div>
|
|
3
|
+
<h1>Blog</h1>
|
|
4
|
+
<p>Welcome to our blog! Here are some recent posts:</p>
|
|
5
|
+
|
|
6
|
+
<div style="margin: 20px 0; padding: 20px; border: 1px solid #ccc; border-radius: 8px;">
|
|
7
|
+
<h3>Route Information</h3>
|
|
8
|
+
<p>This page is rendered from <code>pages/blog/index.zen</code></p>
|
|
9
|
+
<p>Current path: <code>/blog</code></p>
|
|
10
|
+
</div>
|
|
11
|
+
|
|
12
|
+
<div style="margin: 20px 0;">
|
|
13
|
+
<h3>Recent Posts</h3>
|
|
14
|
+
<ul>
|
|
15
|
+
<li><a href="/blog/1">Getting Started with Zenith</a></li>
|
|
16
|
+
<li><a href="/blog/2">File-Based Routing Explained</a></li>
|
|
17
|
+
<li><a href="/blog/3">Building Components</a></li>
|
|
18
|
+
<li><a href="/blog/hello-world">Hello World Post</a></li>
|
|
19
|
+
</ul>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<nav style="margin-top: 20px;">
|
|
23
|
+
<h3>Navigation</h3>
|
|
24
|
+
<ul style="list-style: none; padding: 0;">
|
|
25
|
+
<li><a href="/">Home</a></li>
|
|
26
|
+
<li><a href="/about">About</a></li>
|
|
27
|
+
<li><a href="/blog">Blog (current)</a></li>
|
|
28
|
+
</ul>
|
|
29
|
+
</nav>
|
|
30
|
+
</div>
|
|
31
|
+
</Main>
|
|
32
|
+
|