@zenithbuild/core 1.3.13 → 1.3.17
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/bin/zenith.js +1 -1
- package/cli/commands/build.ts +1 -1
- package/cli/commands/dev.ts +11 -7
- package/dist/bin/zen-build.d.ts +2 -0
- package/dist/bin/zen-build.d.ts.map +1 -0
- package/dist/bin/zen-build.js +3 -0
- package/dist/bin/zen-build.js.map +1 -0
- package/dist/bin/zen-dev.d.ts +2 -0
- package/dist/bin/zen-dev.d.ts.map +1 -0
- package/dist/bin/zen-dev.js +3 -0
- package/dist/bin/zen-dev.js.map +1 -0
- package/dist/bin/zen-preview.d.ts +2 -0
- package/dist/bin/zen-preview.d.ts.map +1 -0
- package/dist/bin/zen-preview.js +3 -0
- package/dist/bin/zen-preview.js.map +1 -0
- package/dist/bin/zenith.d.ts +2 -0
- package/dist/bin/zenith.d.ts.map +1 -0
- package/dist/bin/zenith.js +3 -0
- package/dist/bin/zenith.js.map +1 -0
- package/dist/cli/commands/add.d.ts +10 -0
- package/dist/cli/commands/add.d.ts.map +1 -0
- package/dist/cli/commands/add.js +27 -0
- package/dist/cli/commands/add.js.map +1 -0
- package/dist/cli/commands/build.d.ts +10 -0
- package/dist/cli/commands/build.d.ts.map +1 -0
- package/dist/cli/commands/build.js +29 -0
- package/dist/cli/commands/build.js.map +1 -0
- package/dist/cli/commands/create.d.ts +11 -0
- package/dist/cli/commands/create.d.ts.map +1 -0
- package/dist/cli/commands/create.js +625 -0
- package/dist/cli/commands/create.js.map +1 -0
- package/dist/cli/commands/dev.d.ts +24 -0
- package/dist/cli/commands/dev.d.ts.map +1 -0
- package/dist/cli/commands/dev.js +402 -0
- package/dist/cli/commands/dev.js.map +1 -0
- package/dist/cli/commands/index.d.ts +16 -0
- package/dist/cli/commands/index.d.ts.map +1 -0
- package/dist/cli/commands/index.js +101 -0
- package/dist/cli/commands/index.js.map +1 -0
- package/dist/cli/commands/preview.d.ts +10 -0
- package/dist/cli/commands/preview.d.ts.map +1 -0
- package/dist/cli/commands/preview.js +49 -0
- package/dist/cli/commands/preview.js.map +1 -0
- package/dist/cli/commands/remove.d.ts +7 -0
- package/dist/cli/commands/remove.d.ts.map +1 -0
- package/dist/cli/commands/remove.js +27 -0
- package/dist/cli/commands/remove.js.map +1 -0
- package/dist/cli/main.d.ts +11 -0
- package/dist/cli/main.d.ts.map +1 -0
- package/dist/cli/main.js +88 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/cli/utils/branding.d.ts +51 -0
- package/dist/cli/utils/branding.d.ts.map +1 -0
- package/dist/cli/utils/branding.js +147 -0
- package/dist/cli/utils/branding.js.map +1 -0
- package/dist/cli/utils/logger.d.ts +15 -0
- package/dist/cli/utils/logger.d.ts.map +1 -0
- package/dist/cli/utils/logger.js +40 -0
- package/dist/cli/utils/logger.js.map +1 -0
- package/dist/cli/utils/plugin-manager.d.ts +34 -0
- package/dist/cli/utils/plugin-manager.d.ts.map +1 -0
- package/dist/cli/utils/plugin-manager.js +89 -0
- package/dist/cli/utils/plugin-manager.js.map +1 -0
- package/dist/cli/utils/project.d.ts +24 -0
- package/dist/cli/utils/project.d.ts.map +1 -0
- package/dist/cli/utils/project.js +62 -0
- package/dist/cli/utils/project.js.map +1 -0
- package/dist/core/components/index.d.ts +10 -0
- package/dist/core/components/index.d.ts.map +1 -0
- package/dist/core/components/index.js +14 -0
- package/dist/core/components/index.js.map +1 -0
- package/dist/core/config.d.ts +2 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +2 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/index.d.ts +63 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +78 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/lifecycle/index.d.ts +17 -0
- package/dist/core/lifecycle/index.d.ts.map +1 -0
- package/dist/core/lifecycle/index.js +20 -0
- package/dist/core/lifecycle/index.js.map +1 -0
- package/dist/core/lifecycle/zen-mount.d.ts +67 -0
- package/dist/core/lifecycle/zen-mount.d.ts.map +1 -0
- package/dist/core/lifecycle/zen-mount.js +152 -0
- package/dist/core/lifecycle/zen-mount.js.map +1 -0
- package/dist/core/lifecycle/zen-unmount.d.ts +55 -0
- package/dist/core/lifecycle/zen-unmount.d.ts.map +1 -0
- package/dist/core/lifecycle/zen-unmount.js +77 -0
- package/dist/core/lifecycle/zen-unmount.js.map +1 -0
- package/dist/core/reactivity/index.d.ts +31 -0
- package/dist/core/reactivity/index.d.ts.map +1 -0
- package/dist/core/reactivity/index.js +34 -0
- package/dist/core/reactivity/index.js.map +1 -0
- package/dist/core/reactivity/tracking.d.ts +75 -0
- package/dist/core/reactivity/tracking.d.ts.map +1 -0
- package/dist/core/reactivity/tracking.js +137 -0
- package/dist/core/reactivity/tracking.js.map +1 -0
- package/dist/core/reactivity/zen-batch.d.ts +46 -0
- package/dist/core/reactivity/zen-batch.d.ts.map +1 -0
- package/dist/core/reactivity/zen-batch.js +55 -0
- package/dist/core/reactivity/zen-batch.js.map +1 -0
- package/dist/core/reactivity/zen-effect.d.ts +49 -0
- package/dist/core/reactivity/zen-effect.d.ts.map +1 -0
- package/dist/core/reactivity/zen-effect.js +99 -0
- package/dist/core/reactivity/zen-effect.js.map +1 -0
- package/dist/core/reactivity/zen-memo.d.ts +44 -0
- package/dist/core/reactivity/zen-memo.d.ts.map +1 -0
- package/dist/core/reactivity/zen-memo.js +101 -0
- package/dist/core/reactivity/zen-memo.js.map +1 -0
- package/dist/core/reactivity/zen-ref.d.ts +45 -0
- package/dist/core/reactivity/zen-ref.d.ts.map +1 -0
- package/dist/core/reactivity/zen-ref.js +35 -0
- package/dist/core/reactivity/zen-ref.js.map +1 -0
- package/dist/core/reactivity/zen-signal.d.ts +49 -0
- package/dist/core/reactivity/zen-signal.d.ts.map +1 -0
- package/dist/core/reactivity/zen-signal.js +85 -0
- package/dist/core/reactivity/zen-signal.js.map +1 -0
- package/dist/core/reactivity/zen-state.d.ts +36 -0
- package/dist/core/reactivity/zen-state.d.ts.map +1 -0
- package/dist/core/reactivity/zen-state.js +148 -0
- package/dist/core/reactivity/zen-state.js.map +1 -0
- package/dist/core/reactivity/zen-untrack.d.ts +39 -0
- package/dist/core/reactivity/zen-untrack.d.ts.map +1 -0
- package/dist/core/reactivity/zen-untrack.js +42 -0
- package/dist/core/reactivity/zen-untrack.js.map +1 -0
- package/package.json +17 -14
- package/tsconfig.json +24 -26
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @zenithbuild/cli - Dev Command
|
|
3
|
+
*
|
|
4
|
+
* Development server with HMR support.
|
|
5
|
+
*
|
|
6
|
+
* ═══════════════════════════════════════════════════════════════════════════════
|
|
7
|
+
* CLI HARDENING: BLIND ORCHESTRATOR PATTERN
|
|
8
|
+
* ═══════════════════════════════════════════════════════════════════════════════
|
|
9
|
+
*
|
|
10
|
+
* This file follows the CLI Hardening Plan:
|
|
11
|
+
* - NO plugin-specific branching (no `if (hasContentPlugin)`)
|
|
12
|
+
* - NO semantic helpers (no `getContentData()`)
|
|
13
|
+
* - NO plugin type imports or casts
|
|
14
|
+
* - ONLY opaque data forwarding via hooks
|
|
15
|
+
*
|
|
16
|
+
* The CLI dispatches lifecycle hooks and collects payloads.
|
|
17
|
+
* It never understands what the data means.
|
|
18
|
+
* ═══════════════════════════════════════════════════════════════════════════════
|
|
19
|
+
*/
|
|
20
|
+
import path from 'path';
|
|
21
|
+
import fs from 'fs';
|
|
22
|
+
import { serve } from 'bun';
|
|
23
|
+
import { requireProject } from '../utils/project';
|
|
24
|
+
import * as logger from '../utils/logger';
|
|
25
|
+
import * as brand from '../utils/branding';
|
|
26
|
+
import { compile, loadZenithConfig, PluginRegistry, createPluginContext, getPluginDataByNamespace, createBridgeAPI, runPluginHooks, collectHookReturns, buildRuntimeEnvelope, clearHooks } from '@zenithbuild/compiler';
|
|
27
|
+
import { compileCssAsync, resolveGlobalsCss, bundlePageScript, generateBundleJS, discoverComponents } from '@zenithbuild/bundler';
|
|
28
|
+
import { generateRouteDefinition } from '@zenithbuild/router/manifest';
|
|
29
|
+
const pageCache = new Map();
|
|
30
|
+
export async function dev(options = {}) {
|
|
31
|
+
const project = requireProject();
|
|
32
|
+
const port = options.port || parseInt(process.env.PORT || '3000', 10);
|
|
33
|
+
const pagesDir = project.pagesDir;
|
|
34
|
+
const rootDir = project.root;
|
|
35
|
+
// Load zenith.config.ts if present
|
|
36
|
+
const config = await loadZenithConfig(rootDir);
|
|
37
|
+
const registry = new PluginRegistry();
|
|
38
|
+
const bridgeAPI = createBridgeAPI();
|
|
39
|
+
// Clear any previously registered hooks (important for restarts)
|
|
40
|
+
clearHooks();
|
|
41
|
+
logger.debug(`Config plugins: ${config.plugins?.length ?? 0}`);
|
|
42
|
+
// ============================================
|
|
43
|
+
// Plugin Registration (Unconditional)
|
|
44
|
+
// ============================================
|
|
45
|
+
// CLI registers ALL plugins without checking which ones exist.
|
|
46
|
+
// Each plugin decides what hooks to register.
|
|
47
|
+
for (const plugin of config.plugins || []) {
|
|
48
|
+
logger.debug(`Registering plugin: ${plugin.name}`);
|
|
49
|
+
registry.register(plugin);
|
|
50
|
+
// Let plugin register its CLI hooks (if it wants to)
|
|
51
|
+
// CLI does NOT check what the plugin is - it just offers the API
|
|
52
|
+
logger.debug(`About to call registerCLI for: ${plugin.name}`);
|
|
53
|
+
if (plugin.registerCLI) {
|
|
54
|
+
plugin.registerCLI(bridgeAPI);
|
|
55
|
+
logger.debug(`registerCLI completed for: ${plugin.name}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// ============================================
|
|
59
|
+
// Plugin Initialization (Unconditional)
|
|
60
|
+
// ============================================
|
|
61
|
+
// Initialize ALL plugins unconditionally.
|
|
62
|
+
// If no plugins, this is a no-op. CLI doesn't branch on plugin presence.
|
|
63
|
+
logger.debug('About to call registry.initAll...');
|
|
64
|
+
await registry.initAll(createPluginContext(rootDir));
|
|
65
|
+
logger.debug('registry.initAll completed');
|
|
66
|
+
// Create hook context - CLI provides this but NEVER uses getPluginData itself
|
|
67
|
+
const hookCtx = {
|
|
68
|
+
projectRoot: rootDir,
|
|
69
|
+
getPluginData: getPluginDataByNamespace
|
|
70
|
+
};
|
|
71
|
+
logger.debug('hookCtx created, calling runPluginHooks...');
|
|
72
|
+
// Dispatch lifecycle hook - plugins decide if they care
|
|
73
|
+
await runPluginHooks('cli:dev:start', hookCtx);
|
|
74
|
+
logger.debug('runPluginHooks completed');
|
|
75
|
+
// ============================================
|
|
76
|
+
// CSS Compilation (Compiler-Owned)
|
|
77
|
+
// ============================================
|
|
78
|
+
const globalsCssPath = resolveGlobalsCss(rootDir);
|
|
79
|
+
let compiledCss = '';
|
|
80
|
+
if (globalsCssPath) {
|
|
81
|
+
logger.debug(`Compiling CSS: ${path.relative(rootDir, globalsCssPath)}`);
|
|
82
|
+
const cssResult = await compileCssAsync({ input: globalsCssPath, output: ':memory:' });
|
|
83
|
+
if (cssResult.success) {
|
|
84
|
+
compiledCss = cssResult.css;
|
|
85
|
+
logger.debug(`CSS compiled in ${cssResult.duration}ms`);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
console.error('[Zenith] CSS compilation failed:', cssResult.error);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const clients = new Set();
|
|
92
|
+
// Branded Startup Panel
|
|
93
|
+
brand.showServerPanel({
|
|
94
|
+
project: project.root,
|
|
95
|
+
pages: project.pagesDir,
|
|
96
|
+
url: `http://localhost:${port}`,
|
|
97
|
+
hmr: true,
|
|
98
|
+
mode: 'In-memory compilation'
|
|
99
|
+
});
|
|
100
|
+
// File extensions that should be served as static assets
|
|
101
|
+
const STATIC_EXTENSIONS = new Set([
|
|
102
|
+
'.js', '.css', '.ico', '.png', '.jpg', '.jpeg', '.gif', '.svg',
|
|
103
|
+
'.webp', '.woff', '.woff2', '.ttf', '.eot', '.json', '.map'
|
|
104
|
+
]);
|
|
105
|
+
/**
|
|
106
|
+
* Compile a .zen page in memory
|
|
107
|
+
*/
|
|
108
|
+
async function compilePageInMemory(pagePath) {
|
|
109
|
+
try {
|
|
110
|
+
const componentsDir = path.join(pagesDir, '../components');
|
|
111
|
+
const layoutsDir = path.join(pagesDir, '../layouts');
|
|
112
|
+
// Discover layouts removed in Phase A1
|
|
113
|
+
// const layouts = discoverLayouts(layoutsDir)
|
|
114
|
+
// Discover components for resolution logic
|
|
115
|
+
// We need layouts to be available as components too (e.g. <DefaultLayout>)
|
|
116
|
+
const componentsMap = new Map();
|
|
117
|
+
if (fs.existsSync(componentsDir)) {
|
|
118
|
+
const comps = discoverComponents(componentsDir);
|
|
119
|
+
for (const [k, v] of comps)
|
|
120
|
+
componentsMap.set(k, v);
|
|
121
|
+
}
|
|
122
|
+
if (fs.existsSync(layoutsDir)) {
|
|
123
|
+
const layoutComps = discoverComponents(layoutsDir);
|
|
124
|
+
for (const [k, v] of layoutComps) {
|
|
125
|
+
// Start with uppercase = component
|
|
126
|
+
if (k[0] === k[0]?.toUpperCase()) {
|
|
127
|
+
componentsMap.set(k, v);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const source = fs.readFileSync(pagePath, 'utf-8');
|
|
132
|
+
let processedSource = source;
|
|
133
|
+
// Legacy layout wrapping (implicit)
|
|
134
|
+
// If the page doesn't explicitly use the layout, we might wrap it?
|
|
135
|
+
// But if users use <DefaultLayout>, that's handled by component resolution.
|
|
136
|
+
// Legacy layout wrapping removed in Phase A1
|
|
137
|
+
/*
|
|
138
|
+
let layoutToUse = layouts.get('DefaultLayout')
|
|
139
|
+
if (layoutToUse && !source.includes('<DefaultLayout')) {
|
|
140
|
+
processedSource = processLayout(source, layoutToUse)
|
|
141
|
+
}
|
|
142
|
+
*/
|
|
143
|
+
const result = await compile(processedSource, pagePath, {
|
|
144
|
+
components: componentsMap
|
|
145
|
+
});
|
|
146
|
+
if (!result.finalized)
|
|
147
|
+
throw new Error('Compilation failed');
|
|
148
|
+
logger.debug(`Finalized JS Length: ${result.finalized.js.length}`);
|
|
149
|
+
logger.debug(`Finalized JS Preview: ${result.finalized.js.substring(0, 500)}`);
|
|
150
|
+
const routeDef = generateRouteDefinition(pagePath, pagesDir);
|
|
151
|
+
// Safely strip imports from the top of the script
|
|
152
|
+
// This relies on the fact that duplicate imports (from Rust codegen)
|
|
153
|
+
// appear at the beginning of result.finalized.js
|
|
154
|
+
let jsLines = result.finalized.js.split('\n');
|
|
155
|
+
// Remove lines from top that are imports, whitespace, or comments
|
|
156
|
+
while (jsLines.length > 0 && jsLines[0] !== undefined) {
|
|
157
|
+
const line = jsLines[0].trim();
|
|
158
|
+
if (line.startsWith('import ') ||
|
|
159
|
+
line === '' ||
|
|
160
|
+
line.startsWith('//') ||
|
|
161
|
+
line.startsWith('/*') ||
|
|
162
|
+
line.startsWith('*')) {
|
|
163
|
+
jsLines.shift();
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
let jsWithoutImports = jsLines.join('\n');
|
|
170
|
+
// Combine: structured imports first, then cleaned script body
|
|
171
|
+
const fullScript = (result.finalized.npmImports || '') + '\n\n' + jsWithoutImports;
|
|
172
|
+
logger.debug(`Page Imports: ${result.finalized.npmImports ? result.finalized.npmImports.split('\n').length : 0} lines`);
|
|
173
|
+
// Bundle ONLY if compiler emitted a BundlePlan (no inference)
|
|
174
|
+
let bundledScript = fullScript;
|
|
175
|
+
if (result.finalized.bundlePlan) {
|
|
176
|
+
// Compiler decided bundling is needed - pass plan with proper resolve roots
|
|
177
|
+
const plan = {
|
|
178
|
+
...result.finalized.bundlePlan,
|
|
179
|
+
entry: fullScript,
|
|
180
|
+
resolveRoots: [path.join(rootDir, 'node_modules'), 'node_modules']
|
|
181
|
+
};
|
|
182
|
+
bundledScript = await bundlePageScript(plan);
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
html: result.finalized.html,
|
|
186
|
+
script: bundledScript,
|
|
187
|
+
styles: result.finalized.styles || '',
|
|
188
|
+
route: routeDef.path,
|
|
189
|
+
lastModified: Date.now()
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
logger.error(`Compilation error: ${error.message}`);
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Generate dev HTML with plugin data envelope
|
|
199
|
+
*
|
|
200
|
+
* CLI collects payloads from plugins via 'cli:runtime:collect' hook.
|
|
201
|
+
* It serializes blindly - never inspecting what's inside.
|
|
202
|
+
*/
|
|
203
|
+
async function generateDevHTML(page) {
|
|
204
|
+
// Runtime MUST be a regular script (not module) to execute synchronously
|
|
205
|
+
// before the page module script runs and needs its globals
|
|
206
|
+
const runtimeTag = `<script src="/runtime.js"></script>`;
|
|
207
|
+
const scriptTag = `<script type="module">\n${page.script}\n</script>`;
|
|
208
|
+
const allScripts = `${runtimeTag}\n${scriptTag}`;
|
|
209
|
+
let html = page.html;
|
|
210
|
+
if (html.includes('</head>')) {
|
|
211
|
+
html = html.replace('</head>', `${allScripts}\n</head>`);
|
|
212
|
+
}
|
|
213
|
+
else if (html.includes('</body>')) {
|
|
214
|
+
html = html.replace('</body>', `${allScripts}\n</body>`);
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
html = `${html}\n${allScripts}`;
|
|
218
|
+
}
|
|
219
|
+
if (!html.trimStart().toLowerCase().startsWith('<!doctype')) {
|
|
220
|
+
html = `<!DOCTYPE html>\n${html}`;
|
|
221
|
+
}
|
|
222
|
+
return html;
|
|
223
|
+
}
|
|
224
|
+
// ============================================
|
|
225
|
+
// File Watcher (Plugin-Agnostic)
|
|
226
|
+
// ============================================
|
|
227
|
+
// CLI watches files but delegates decisions to plugins via hooks.
|
|
228
|
+
// No branching on file types that are "content" vs "not content".
|
|
229
|
+
const watcher = fs.watch(path.join(pagesDir, '..'), { recursive: true }, async (event, filename) => {
|
|
230
|
+
if (!filename)
|
|
231
|
+
return;
|
|
232
|
+
// Dispatch file change hook to ALL plugins
|
|
233
|
+
// Each plugin decides if it cares about this file
|
|
234
|
+
await runPluginHooks('cli:dev:file-change', {
|
|
235
|
+
...hookCtx,
|
|
236
|
+
filename,
|
|
237
|
+
event
|
|
238
|
+
});
|
|
239
|
+
if (filename.endsWith('.zen')) {
|
|
240
|
+
logger.hmr('Page', filename);
|
|
241
|
+
// Clear page cache to force fresh compilation on next request
|
|
242
|
+
pageCache.clear();
|
|
243
|
+
// Recompile CSS for new Tailwind classes in .zen files
|
|
244
|
+
if (globalsCssPath) {
|
|
245
|
+
const cssResult = await compileCssAsync({ input: globalsCssPath, output: ':memory:' });
|
|
246
|
+
if (cssResult.success) {
|
|
247
|
+
compiledCss = cssResult.css;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
// Broadcast page reload AFTER cache cleared and CSS ready
|
|
251
|
+
for (const client of clients) {
|
|
252
|
+
client.send(JSON.stringify({ type: 'reload' }));
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
else if (filename.endsWith('.css')) {
|
|
256
|
+
logger.hmr('CSS', filename);
|
|
257
|
+
// Recompile CSS
|
|
258
|
+
if (globalsCssPath) {
|
|
259
|
+
const cssResult = await compileCssAsync({ input: globalsCssPath, output: ':memory:' });
|
|
260
|
+
if (cssResult.success) {
|
|
261
|
+
compiledCss = cssResult.css;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
for (const client of clients) {
|
|
265
|
+
client.send(JSON.stringify({ type: 'style-update', url: '/assets/styles.css' }));
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
// For all other file changes, re-initialize plugins unconditionally
|
|
270
|
+
// Plugins decide internally whether they need to reload data
|
|
271
|
+
// CLI does NOT branch on "is this a content file"
|
|
272
|
+
await registry.initAll(createPluginContext(rootDir));
|
|
273
|
+
// Broadcast reload for any non-code file changes
|
|
274
|
+
for (const client of clients) {
|
|
275
|
+
client.send(JSON.stringify({ type: 'reload' }));
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
const server = serve({
|
|
280
|
+
port,
|
|
281
|
+
async fetch(req, server) {
|
|
282
|
+
const startTime = performance.now();
|
|
283
|
+
const url = new URL(req.url);
|
|
284
|
+
const pathname = url.pathname;
|
|
285
|
+
const ext = path.extname(pathname).toLowerCase();
|
|
286
|
+
// Upgrade to WebSocket for HMR
|
|
287
|
+
if (pathname === '/hmr') {
|
|
288
|
+
const upgraded = server.upgrade(req);
|
|
289
|
+
if (upgraded)
|
|
290
|
+
return undefined;
|
|
291
|
+
}
|
|
292
|
+
// Handle Zenith assets
|
|
293
|
+
if (pathname === '/runtime.js') {
|
|
294
|
+
// Collect runtime payloads from ALL plugins
|
|
295
|
+
const payloads = await collectHookReturns('cli:runtime:collect', hookCtx);
|
|
296
|
+
const envelope = buildRuntimeEnvelope(payloads);
|
|
297
|
+
const response = new Response(generateBundleJS(envelope), {
|
|
298
|
+
headers: { 'Content-Type': 'application/javascript; charset=utf-8' }
|
|
299
|
+
});
|
|
300
|
+
logger.route('GET', pathname, 200, Math.round(performance.now() - startTime), 0, Math.round(performance.now() - startTime));
|
|
301
|
+
return response;
|
|
302
|
+
}
|
|
303
|
+
// Serve compiler-owned CSS (Tailwind compiled)
|
|
304
|
+
if (pathname === '/assets/styles.css') {
|
|
305
|
+
const response = new Response(compiledCss, {
|
|
306
|
+
headers: { 'Content-Type': 'text/css; charset=utf-8' }
|
|
307
|
+
});
|
|
308
|
+
logger.route('GET', pathname, 200, Math.round(performance.now() - startTime), 0, Math.round(performance.now() - startTime));
|
|
309
|
+
return response;
|
|
310
|
+
}
|
|
311
|
+
// Legacy: also support /styles/globals.css or /styles/global.css for backwards compat
|
|
312
|
+
if (pathname === '/styles/globals.css' || pathname === '/styles/global.css') {
|
|
313
|
+
const response = new Response(compiledCss, {
|
|
314
|
+
headers: { 'Content-Type': 'text/css; charset=utf-8' }
|
|
315
|
+
});
|
|
316
|
+
logger.route('GET', pathname, 200, Math.round(performance.now() - startTime), 0, Math.round(performance.now() - startTime));
|
|
317
|
+
return response;
|
|
318
|
+
}
|
|
319
|
+
// Static files
|
|
320
|
+
if (STATIC_EXTENSIONS.has(ext)) {
|
|
321
|
+
const publicPath = path.join(pagesDir, '../public', pathname);
|
|
322
|
+
if (fs.existsSync(publicPath)) {
|
|
323
|
+
const response = new Response(Bun.file(publicPath));
|
|
324
|
+
logger.route('GET', pathname, 200, Math.round(performance.now() - startTime), 0, Math.round(performance.now() - startTime));
|
|
325
|
+
return response;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
// Zenith Pages
|
|
329
|
+
const pagePath = findPageForRoute(pathname, pagesDir);
|
|
330
|
+
if (pagePath) {
|
|
331
|
+
const compileStart = performance.now();
|
|
332
|
+
let cached = pageCache.get(pagePath);
|
|
333
|
+
const stat = fs.statSync(pagePath);
|
|
334
|
+
if (!cached || stat.mtimeMs > cached.lastModified) {
|
|
335
|
+
cached = await compilePageInMemory(pagePath) || undefined;
|
|
336
|
+
if (cached)
|
|
337
|
+
pageCache.set(pagePath, cached);
|
|
338
|
+
}
|
|
339
|
+
const compileEnd = performance.now();
|
|
340
|
+
if (cached) {
|
|
341
|
+
const renderStart = performance.now();
|
|
342
|
+
const html = await generateDevHTML(cached);
|
|
343
|
+
const renderEnd = performance.now();
|
|
344
|
+
const totalTime = Math.round(performance.now() - startTime);
|
|
345
|
+
const compileTime = Math.round(compileEnd - compileStart);
|
|
346
|
+
const renderTime = Math.round(renderEnd - renderStart);
|
|
347
|
+
logger.route('GET', pathname, 200, totalTime, compileTime, renderTime);
|
|
348
|
+
return new Response(html, { headers: { 'Content-Type': 'text/html; charset=utf-8' } });
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
logger.route('GET', pathname, 404, Math.round(performance.now() - startTime), 0, 0);
|
|
352
|
+
return new Response('Not Found', { status: 404 });
|
|
353
|
+
},
|
|
354
|
+
websocket: {
|
|
355
|
+
open(ws) {
|
|
356
|
+
clients.add(ws);
|
|
357
|
+
},
|
|
358
|
+
close(ws) {
|
|
359
|
+
clients.delete(ws);
|
|
360
|
+
},
|
|
361
|
+
message() { }
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
process.on('SIGINT', () => {
|
|
365
|
+
watcher.close();
|
|
366
|
+
server.stop();
|
|
367
|
+
process.exit(0);
|
|
368
|
+
});
|
|
369
|
+
await new Promise(() => { });
|
|
370
|
+
}
|
|
371
|
+
function findPageForRoute(route, pagesDir) {
|
|
372
|
+
// 1. Try exact match first (e.g., /about -> about.zen)
|
|
373
|
+
const exactPath = path.join(pagesDir, route === '/' ? 'index.zen' : `${route.slice(1)}.zen`);
|
|
374
|
+
if (fs.existsSync(exactPath))
|
|
375
|
+
return exactPath;
|
|
376
|
+
// 2. Try index.zen in directory (e.g., /about -> about/index.zen)
|
|
377
|
+
const indexPath = path.join(pagesDir, route === '/' ? 'index.zen' : `${route.slice(1)}/index.zen`);
|
|
378
|
+
if (fs.existsSync(indexPath))
|
|
379
|
+
return indexPath;
|
|
380
|
+
// 3. Try dynamic routes [slug].zen, [...slug].zen
|
|
381
|
+
// Walk up the path looking for dynamic segments
|
|
382
|
+
const segments = route === '/' ? [] : route.slice(1).split('/').filter(Boolean);
|
|
383
|
+
// Try matching with dynamic [slug].zen at each level
|
|
384
|
+
for (let i = segments.length - 1; i >= 0; i--) {
|
|
385
|
+
const staticPart = segments.slice(0, i).join('/');
|
|
386
|
+
const baseDir = staticPart ? path.join(pagesDir, staticPart) : pagesDir;
|
|
387
|
+
// Check for [slug].zen (single segment catch)
|
|
388
|
+
const singleDynamicPath = path.join(baseDir, '[slug].zen');
|
|
389
|
+
if (fs.existsSync(singleDynamicPath))
|
|
390
|
+
return singleDynamicPath;
|
|
391
|
+
// Check for [...slug].zen (catch-all)
|
|
392
|
+
const catchAllPath = path.join(baseDir, '[...slug].zen');
|
|
393
|
+
if (fs.existsSync(catchAllPath))
|
|
394
|
+
return catchAllPath;
|
|
395
|
+
}
|
|
396
|
+
// 4. Check for catch-all at root
|
|
397
|
+
const rootCatchAll = path.join(pagesDir, '[...slug].zen');
|
|
398
|
+
if (fs.existsSync(rootCatchAll))
|
|
399
|
+
return rootCatchAll;
|
|
400
|
+
return null;
|
|
401
|
+
}
|
|
402
|
+
//# sourceMappingURL=dev.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../../cli/commands/dev.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,EAAE,KAAK,EAAwB,MAAM,KAAK,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAA;AACzC,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAA;AAC1C,OAAO,EACH,OAAO,EACP,gBAAgB,EAChB,cAAc,EACd,mBAAmB,EACnB,wBAAwB,EACxB,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,oBAAoB,EACpB,UAAU,EAEb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACH,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EACrB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AActE,MAAM,SAAS,GAAG,IAAI,GAAG,EAAwB,CAAA;AAQjD,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,UAAsB,EAAE;IAC9C,MAAM,OAAO,GAAG,cAAc,EAAE,CAAA;IAChC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,MAAM,EAAE,EAAE,CAAC,CAAA;IACrE,MAA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GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5C,MAAM,UAAU,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACjD,MAAM,OAAO,GAAG,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAA;QAEvE,8CAA8C;QAC9C,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAA;QAC1D,IAAI,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC;YAAE,OAAO,iBAAiB,CAAA;QAE9D,sCAAsC;QACtC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,eAAe,CAAC,CAAA;QACxD,IAAI,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC;YAAE,OAAO,YAAY,CAAA;IACxD,CAAC;IAED,iCAAiC;IACjC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAA;IACzD,IAAI,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC;QAAE,OAAO,YAAY,CAAA;IAEpD,OAAO,IAAI,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @zenithbuild/cli - Command Registry
|
|
3
|
+
*
|
|
4
|
+
* Central registry for all CLI commands
|
|
5
|
+
*/
|
|
6
|
+
export interface Command {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
usage: string;
|
|
10
|
+
run: (args: string[], options: Record<string, string>) => Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export declare const commands: Command[];
|
|
13
|
+
export declare const placeholderCommands: string[];
|
|
14
|
+
export declare function getCommand(name: string): Command | undefined;
|
|
15
|
+
export declare function showHelp(): void;
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../cli/commands/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH,MAAM,WAAW,OAAO;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CAC1E;AAED,eAAO,MAAM,QAAQ,EAAE,OAAO,EAkE7B,CAAA;AAGD,eAAO,MAAM,mBAAmB,UAA+B,CAAA;AAE/D,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAE5D;AAED,wBAAgB,QAAQ,IAAI,IAAI,CAe/B"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @zenithbuild/cli - Command Registry
|
|
3
|
+
*
|
|
4
|
+
* Central registry for all CLI commands
|
|
5
|
+
*/
|
|
6
|
+
import { dev } from './dev';
|
|
7
|
+
import { preview } from './preview';
|
|
8
|
+
import { build } from './build';
|
|
9
|
+
import { add } from './add';
|
|
10
|
+
import { remove } from './remove';
|
|
11
|
+
import { create } from './create';
|
|
12
|
+
import * as logger from '../utils/logger';
|
|
13
|
+
export const commands = [
|
|
14
|
+
{
|
|
15
|
+
name: 'create',
|
|
16
|
+
description: 'Create a new Zenith project',
|
|
17
|
+
usage: 'zenith create [project-name]',
|
|
18
|
+
async run(args) {
|
|
19
|
+
const projectName = args[0];
|
|
20
|
+
await create(projectName);
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'dev',
|
|
25
|
+
description: 'Start development server',
|
|
26
|
+
usage: 'zenith dev [--port <port>]',
|
|
27
|
+
async run(args, options) {
|
|
28
|
+
const opts = {};
|
|
29
|
+
if (options.port)
|
|
30
|
+
opts.port = parseInt(options.port, 10);
|
|
31
|
+
await dev(opts);
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'preview',
|
|
36
|
+
description: 'Preview production build',
|
|
37
|
+
usage: 'zenith preview [--port <port>]',
|
|
38
|
+
async run(args, options) {
|
|
39
|
+
const opts = {};
|
|
40
|
+
if (options.port)
|
|
41
|
+
opts.port = parseInt(options.port, 10);
|
|
42
|
+
await preview(opts);
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'build',
|
|
47
|
+
description: 'Build for production',
|
|
48
|
+
usage: 'zenith build [--outDir <dir>]',
|
|
49
|
+
async run(args, options) {
|
|
50
|
+
const opts = {};
|
|
51
|
+
if (options.outDir)
|
|
52
|
+
opts.outDir = options.outDir;
|
|
53
|
+
await build(opts);
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'add',
|
|
58
|
+
description: 'Add a plugin',
|
|
59
|
+
usage: 'zenith add <plugin>',
|
|
60
|
+
async run(args) {
|
|
61
|
+
const pluginName = args[0];
|
|
62
|
+
if (!pluginName) {
|
|
63
|
+
logger.error('Plugin name required');
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
await add(pluginName);
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'remove',
|
|
71
|
+
description: 'Remove a plugin',
|
|
72
|
+
usage: 'zenith remove <plugin>',
|
|
73
|
+
async run(args) {
|
|
74
|
+
const pluginName = args[0];
|
|
75
|
+
if (!pluginName) {
|
|
76
|
+
logger.error('Plugin name required');
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
await remove(pluginName);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
];
|
|
83
|
+
// Placeholder commands for future expansion
|
|
84
|
+
export const placeholderCommands = ['test', 'export', 'deploy'];
|
|
85
|
+
export function getCommand(name) {
|
|
86
|
+
return commands.find(c => c.name === name);
|
|
87
|
+
}
|
|
88
|
+
export function showHelp() {
|
|
89
|
+
logger.header('Zenith CLI');
|
|
90
|
+
console.log('Usage: zenith <command> [options]\n');
|
|
91
|
+
console.log('Commands:');
|
|
92
|
+
for (const cmd of commands) {
|
|
93
|
+
console.log(` ${cmd.name.padEnd(12)} ${cmd.description}`);
|
|
94
|
+
}
|
|
95
|
+
console.log('\nComing soon:');
|
|
96
|
+
for (const cmd of placeholderCommands) {
|
|
97
|
+
console.log(` ${cmd.padEnd(12)} (not yet implemented)`);
|
|
98
|
+
}
|
|
99
|
+
console.log('\nRun `zenith <command> --help` for command-specific help.');
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../cli/commands/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,GAAG,EAAmB,MAAM,OAAO,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAuB,MAAM,WAAW,CAAA;AACxD,OAAO,EAAE,KAAK,EAAqB,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,GAAG,EAAmB,MAAM,OAAO,CAAA;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAA;AASzC,MAAM,CAAC,MAAM,QAAQ,GAAc;IAC/B;QACI,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,6BAA6B;QAC1C,KAAK,EAAE,8BAA8B;QACrC,KAAK,CAAC,GAAG,CAAC,IAAI;YACV,MAAM,WAAW,GAAG,IAAI,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,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAA;IAC7B,KAAK,MAAM,GAAG,IAAI,mBAAmB,EAAE,CAAC;QACpC,OAAO,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,wBAAwB,CAAC,CAAA;IAC5D,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,4DAA4D,CAAC,CAAA;AAC7E,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @zenithbuild/cli - Preview Command
|
|
3
|
+
*
|
|
4
|
+
* Serves the production build from the distribution directory.
|
|
5
|
+
*/
|
|
6
|
+
export interface PreviewOptions {
|
|
7
|
+
port?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function preview(options?: PreviewOptions): Promise<void>;
|
|
10
|
+
//# sourceMappingURL=preview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../cli/commands/preview.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,MAAM,WAAW,cAAc;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,wBAAsB,OAAO,CAAC,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CA8CzE"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @zenithbuild/cli - Preview Command
|
|
3
|
+
*
|
|
4
|
+
* Serves the production build from the distribution directory.
|
|
5
|
+
*/
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import { serve } from 'bun';
|
|
8
|
+
import { requireProject } from '../utils/project';
|
|
9
|
+
import * as logger from '../utils/logger';
|
|
10
|
+
export async function preview(options = {}) {
|
|
11
|
+
const project = requireProject();
|
|
12
|
+
const distDir = project.distDir;
|
|
13
|
+
const port = options.port || parseInt(process.env.PORT || '4173', 10);
|
|
14
|
+
logger.header('Zenith Preview Server');
|
|
15
|
+
logger.log(`Serving: ${distDir}`);
|
|
16
|
+
// File extensions that should be served as static assets
|
|
17
|
+
const STATIC_EXTENSIONS = new Set([
|
|
18
|
+
'.js', '.css', '.ico', '.png', '.jpg', '.jpeg', '.gif', '.svg',
|
|
19
|
+
'.webp', '.woff', '.woff2', '.ttf', '.eot', '.json', '.map'
|
|
20
|
+
]);
|
|
21
|
+
const server = serve({
|
|
22
|
+
port,
|
|
23
|
+
async fetch(req) {
|
|
24
|
+
const url = new URL(req.url);
|
|
25
|
+
const pathname = url.pathname;
|
|
26
|
+
const ext = path.extname(pathname).toLowerCase();
|
|
27
|
+
if (STATIC_EXTENSIONS.has(ext)) {
|
|
28
|
+
const filePath = path.join(distDir, pathname);
|
|
29
|
+
const file = Bun.file(filePath);
|
|
30
|
+
if (await file.exists()) {
|
|
31
|
+
return new Response(file);
|
|
32
|
+
}
|
|
33
|
+
return new Response('Not found', { status: 404 });
|
|
34
|
+
}
|
|
35
|
+
const indexPath = path.join(distDir, 'index.html');
|
|
36
|
+
const indexFile = Bun.file(indexPath);
|
|
37
|
+
if (await indexFile.exists()) {
|
|
38
|
+
return new Response(indexFile, {
|
|
39
|
+
headers: { 'Content-Type': 'text/html; charset=utf-8' }
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return new Response('No production build found. Run `zenith build` first.', { status: 500 });
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
logger.success(`Preview server running at http://localhost:${server.port}`);
|
|
46
|
+
logger.info('Press Ctrl+C to stop');
|
|
47
|
+
await new Promise(() => { });
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=preview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview.js","sourceRoot":"","sources":["../../../cli/commands/preview.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,CAAA;AAC3B,O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