@zenithbuild/core 0.1.0 → 0.3.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/LICENSE +1 -1
- package/README.md +24 -40
- package/bin/cli-source.ts +81 -0
- package/cli/commands/add.ts +37 -0
- package/cli/commands/build.ts +37 -0
- package/cli/commands/create.ts +702 -0
- package/cli/commands/dev.ts +197 -0
- package/cli/commands/index.ts +112 -0
- package/cli/commands/preview.ts +62 -0
- package/cli/commands/remove.ts +33 -0
- package/cli/index.ts +10 -0
- package/cli/utils/branding.ts +153 -0
- package/cli/utils/logger.ts +40 -0
- package/cli/utils/plugin-manager.ts +114 -0
- package/cli/utils/project.ts +71 -0
- package/compiler/build-analyzer.ts +122 -0
- package/compiler/discovery/layouts.ts +61 -0
- package/compiler/index.ts +40 -24
- package/compiler/ir/types.ts +1 -0
- package/compiler/parse/parseScript.ts +29 -5
- package/compiler/parse/parseTemplate.ts +96 -58
- package/compiler/parse/scriptAnalysis.ts +77 -0
- package/compiler/runtime/dataExposure.ts +49 -31
- package/compiler/runtime/generateDOM.ts +18 -17
- package/compiler/runtime/generateHydrationBundle.ts +24 -5
- package/compiler/runtime/transformIR.ts +140 -49
- package/compiler/runtime/wrapExpressionWithLoop.ts +11 -11
- package/compiler/spa-build.ts +70 -153
- package/compiler/ssg-build.ts +412 -0
- package/compiler/transform/layoutProcessor.ts +132 -0
- package/compiler/transform/transformNode.ts +19 -19
- package/dist/cli.js +11645 -0
- package/package.json +22 -2
- package/runtime/bundle-generator.ts +416 -0
- package/runtime/client-runtime.ts +532 -0
- package/.eslintignore +0 -15
- package/.gitattributes +0 -2
- package/.github/ISSUE_TEMPLATE/compiler-errors-for-invalid-state-declarations.md +0 -25
- package/.github/ISSUE_TEMPLATE/new_ticket.yaml +0 -34
- package/.github/pull_request_template.md +0 -15
- package/.github/workflows/discord-changelog.yml +0 -141
- package/.github/workflows/discord-notify.yml +0 -242
- package/.github/workflows/discord-version.yml +0 -195
- package/.prettierignore +0 -13
- package/.prettierrc +0 -21
- package/.zen.d.ts +0 -15
- package/app/components/Button.zen +0 -46
- package/app/components/Link.zen +0 -11
- package/app/favicon.ico +0 -0
- package/app/layouts/Main.zen +0 -59
- package/app/pages/about.zen +0 -23
- package/app/pages/blog/[id].zen +0 -53
- package/app/pages/blog/index.zen +0 -32
- package/app/pages/dynamic-dx.zen +0 -712
- package/app/pages/dynamic-primitives.zen +0 -453
- package/app/pages/index.zen +0 -154
- package/app/pages/navigation-demo.zen +0 -229
- package/app/pages/posts/[...slug].zen +0 -61
- package/app/pages/primitives-demo.zen +0 -273
- 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 +0 -601
- package/assets/logos/README.md +0 -54
- package/assets/logos/zen.icns +0 -0
- package/bun.lock +0 -39
- package/compiler/legacy/binding.ts +0 -254
- package/compiler/legacy/bindings.ts +0 -338
- package/compiler/legacy/component-process.ts +0 -1208
- package/compiler/legacy/component.ts +0 -301
- package/compiler/legacy/event.ts +0 -50
- package/compiler/legacy/expression.ts +0 -1149
- package/compiler/legacy/mutation.ts +0 -280
- package/compiler/legacy/parse.ts +0 -299
- package/compiler/legacy/split.ts +0 -608
- package/compiler/legacy/types.ts +0 -32
- package/docs/COMMENTS.md +0 -111
- package/docs/COMMITS.md +0 -36
- package/docs/CONTRIBUTING.md +0 -116
- package/docs/STYLEGUIDE.md +0 -62
- package/scripts/webhook-proxy.ts +0 -213
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,55 +1,39 @@
|
|
|
1
|
+
# @zenithbuild/core ⚡
|
|
1
2
|
|
|
2
|
-
|
|
3
|
+
The heart of the Zenith framework. High-performance reactive runtime, compiler, and build primitives.
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
## Overview
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
Zenith is a modern reactive web framework designed for maximum performance and developer experience. The core package contains the essential building blocks:
|
|
8
|
+
- **Compiler**: Transforms `.zen` files into optimized JavaScript.
|
|
9
|
+
- **Runtime**: A lightweight, efficient reactive system for the browser.
|
|
10
|
+
- **Router**: Lightweight client-side routing.
|
|
11
|
+
- **Build Primitives**: Tools for dev servers and production builds.
|
|
7
12
|
|
|
8
|
-
|
|
13
|
+
## Key Components
|
|
9
14
|
|
|
10
|
-
|
|
15
|
+
### 1. Compiler (`/compiler`)
|
|
16
|
+
The Zenith compiler handles parsing and transforming Single File Components (`.zen`). It leverages `parse5` for robust HTML parsing and generates highly optimized render functions.
|
|
11
17
|
|
|
12
|
-
|
|
18
|
+
### 2. Runtime (`/runtime`)
|
|
19
|
+
Our runtime is designed to be minimal. It manages the reactive cycle, efficient DOM updates, and lifecycle management (like `zenOnMount`).
|
|
13
20
|
|
|
14
|
-
|
|
21
|
+
### 3. Server (`/bin/zen-dev`, `/bin/zen-build`)
|
|
22
|
+
Low-level binaries for orchestrating development and production environments.
|
|
15
23
|
|
|
16
|
-
|
|
24
|
+
## Architecture
|
|
17
25
|
|
|
18
|
-
|
|
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
|
+
Zenith follows a "Compiler-First" philosophy. We shift as much work as possible to build time, keeping the client-side bundle lean and fast.
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
## Usage (Internal)
|
|
28
29
|
|
|
29
|
-
|
|
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
|
|
30
|
+
This package is typically consumed by the Zenith CLI and other ecosystem tools.
|
|
40
31
|
|
|
32
|
+
```typescript
|
|
33
|
+
import { compile } from '@zenithbuild/core/compiler';
|
|
34
|
+
// ... compile logic
|
|
41
35
|
```
|
|
42
|
-
.zenith files
|
|
43
|
-
↓
|
|
44
|
-
Compiler (parse → analyze → compose → generate)
|
|
45
|
-
↓
|
|
46
|
-
Runtime (navigation + rendering)
|
|
47
|
-
↓
|
|
48
|
-
DOM
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
### Status
|
|
52
36
|
|
|
53
|
-
|
|
37
|
+
## License
|
|
54
38
|
|
|
55
|
-
|
|
39
|
+
MIT
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @zenith/cli - Entry Point
|
|
3
|
+
*
|
|
4
|
+
* Main executable for the Zenith CLI.
|
|
5
|
+
* Handles both "zenith <command>" and direct alias calls (zenith-dev, etc.)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import process from 'node:process'
|
|
9
|
+
import path from 'node:path'
|
|
10
|
+
import { getCommand, showHelp, placeholderCommands } from '../cli/commands/index'
|
|
11
|
+
import * as logger from '../cli/utils/logger'
|
|
12
|
+
|
|
13
|
+
async function main() {
|
|
14
|
+
const args = process.argv.slice(2)
|
|
15
|
+
const invokedAs = path.basename(process.argv[1] || '')
|
|
16
|
+
|
|
17
|
+
let commandName: string | undefined = args[0]
|
|
18
|
+
let commandArgs = args.slice(1)
|
|
19
|
+
|
|
20
|
+
// Handle aliases (e.g. zenith-dev, zen-dev)
|
|
21
|
+
if (invokedAs.includes('dev')) {
|
|
22
|
+
commandName = 'dev'
|
|
23
|
+
commandArgs = args
|
|
24
|
+
} else if (invokedAs.includes('build')) {
|
|
25
|
+
commandName = 'build'
|
|
26
|
+
commandArgs = args
|
|
27
|
+
} else if (invokedAs.includes('preview')) {
|
|
28
|
+
commandName = 'preview'
|
|
29
|
+
commandArgs = args
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (!commandName || commandName === '--help' || commandName === '-h') {
|
|
33
|
+
showHelp()
|
|
34
|
+
process.exit(0)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Filter out options from commandArgs for simple command parsing if needed
|
|
38
|
+
// However, most commands parse their own options
|
|
39
|
+
const filteredArgs = commandArgs.filter((a: string) => !a.startsWith('--'))
|
|
40
|
+
|
|
41
|
+
// Parse options (--key value format)
|
|
42
|
+
const options: Record<string, string> = {}
|
|
43
|
+
for (let i = 0; i < commandArgs.length; i++) {
|
|
44
|
+
const arg = commandArgs[i]!
|
|
45
|
+
if (arg.startsWith('--')) {
|
|
46
|
+
const key = arg.slice(2)
|
|
47
|
+
const value = commandArgs[i + 1]
|
|
48
|
+
if (value && !value.startsWith('--')) {
|
|
49
|
+
options[key] = value
|
|
50
|
+
i++
|
|
51
|
+
} else {
|
|
52
|
+
options[key] = 'true'
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Check for placeholder commands
|
|
58
|
+
if (placeholderCommands.includes(commandName)) {
|
|
59
|
+
logger.warn(`Command "${commandName}" is not yet implemented.`)
|
|
60
|
+
logger.info('This feature is planned for a future release.')
|
|
61
|
+
process.exit(0)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const command = getCommand(commandName)
|
|
65
|
+
|
|
66
|
+
if (!command) {
|
|
67
|
+
logger.error(`Unknown command: ${commandName}`)
|
|
68
|
+
showHelp()
|
|
69
|
+
process.exit(1)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
await command!.run(commandArgs, options)
|
|
74
|
+
} catch (err: unknown) {
|
|
75
|
+
const message = err instanceof Error ? err.message : String(err)
|
|
76
|
+
logger.error(message)
|
|
77
|
+
process.exit(1)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
main()
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @zenith/cli - Add Command
|
|
3
|
+
*
|
|
4
|
+
* Registers a plugin in the project
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { requireProject } from '../utils/project'
|
|
8
|
+
import { addPlugin, hasPlugin } from '../utils/plugin-manager'
|
|
9
|
+
import * as logger from '../utils/logger'
|
|
10
|
+
|
|
11
|
+
export interface AddOptions {
|
|
12
|
+
options?: Record<string, unknown>
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export async function add(pluginName: string, options: AddOptions = {}): Promise<void> {
|
|
16
|
+
requireProject()
|
|
17
|
+
|
|
18
|
+
logger.header('Add Plugin')
|
|
19
|
+
|
|
20
|
+
if (!pluginName) {
|
|
21
|
+
logger.error('Plugin name required. Usage: zenith add <plugin>')
|
|
22
|
+
process.exit(1)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (hasPlugin(pluginName)) {
|
|
26
|
+
logger.warn(`Plugin "${pluginName}" is already registered`)
|
|
27
|
+
return
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const success = addPlugin(pluginName, options.options)
|
|
31
|
+
|
|
32
|
+
if (success) {
|
|
33
|
+
logger.info(`Plugin "${pluginName}" has been registered.`)
|
|
34
|
+
logger.info('Note: You may need to install the package manually:')
|
|
35
|
+
logger.log(` bun add @zenith/plugin-${pluginName}`)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @zenith/cli - Build Command
|
|
3
|
+
*
|
|
4
|
+
* Builds the application for production using SSG.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import path from 'path'
|
|
8
|
+
import { requireProject } from '../utils/project'
|
|
9
|
+
import * as logger from '../utils/logger'
|
|
10
|
+
import { buildSSG } from '../../compiler/ssg-build'
|
|
11
|
+
|
|
12
|
+
export interface BuildOptions {
|
|
13
|
+
outDir?: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export async function build(options: BuildOptions = {}): Promise<void> {
|
|
17
|
+
const project = requireProject()
|
|
18
|
+
const outDir = options.outDir || project.distDir
|
|
19
|
+
|
|
20
|
+
logger.header('Zenith Build')
|
|
21
|
+
logger.log(`Source: ${project.pagesDir}`)
|
|
22
|
+
logger.log(`Output: ${outDir}`)
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
buildSSG({
|
|
26
|
+
pagesDir: project.pagesDir,
|
|
27
|
+
outDir: outDir,
|
|
28
|
+
baseDir: project.root
|
|
29
|
+
})
|
|
30
|
+
logger.success('Build complete!')
|
|
31
|
+
|
|
32
|
+
} catch (err: unknown) {
|
|
33
|
+
const message = err instanceof Error ? err.message : String(err)
|
|
34
|
+
logger.error(`Build failed: ${message}`)
|
|
35
|
+
process.exit(1)
|
|
36
|
+
}
|
|
37
|
+
}
|