@zenithbuild/compiler 1.0.16 → 1.3.1
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/native/compiler-native/compiler-native.node +0 -0
- package/native/compiler-native/index.d.ts +46 -7
- package/native/compiler-native/index.js +332 -17
- package/package.json +2 -2
- package/dist/build-analyzer.d.ts +0 -44
- package/dist/build-analyzer.js +0 -87
- package/dist/bundler.d.ts +0 -31
- package/dist/bundler.js +0 -86
- package/dist/compiler-native-ep39xj7a.node +0 -0
- package/dist/compiler-native-ftk9z446.node +0 -0
- package/dist/core/components/index.d.ts +0 -9
- package/dist/core/components/index.js +0 -13
- package/dist/core/config/index.d.ts +0 -11
- package/dist/core/config/index.js +0 -10
- package/dist/core/config/loader.d.ts +0 -17
- package/dist/core/config/loader.js +0 -60
- package/dist/core/config/types.d.ts +0 -98
- package/dist/core/config/types.js +0 -32
- package/dist/core/index.d.ts +0 -7
- package/dist/core/index.js +0 -6
- package/dist/core/lifecycle/index.d.ts +0 -16
- package/dist/core/lifecycle/index.js +0 -19
- package/dist/core/lifecycle/zen-mount.d.ts +0 -66
- package/dist/core/lifecycle/zen-mount.js +0 -151
- package/dist/core/lifecycle/zen-unmount.d.ts +0 -54
- package/dist/core/lifecycle/zen-unmount.js +0 -76
- package/dist/core/plugins/bridge.d.ts +0 -116
- package/dist/core/plugins/bridge.js +0 -121
- package/dist/core/plugins/index.d.ts +0 -6
- package/dist/core/plugins/index.js +0 -6
- package/dist/core/plugins/registry.d.ts +0 -67
- package/dist/core/plugins/registry.js +0 -112
- package/dist/core/reactivity/index.d.ts +0 -30
- package/dist/core/reactivity/index.js +0 -33
- package/dist/core/reactivity/tracking.d.ts +0 -74
- package/dist/core/reactivity/tracking.js +0 -136
- package/dist/core/reactivity/zen-batch.d.ts +0 -45
- package/dist/core/reactivity/zen-batch.js +0 -54
- package/dist/core/reactivity/zen-effect.d.ts +0 -48
- package/dist/core/reactivity/zen-effect.js +0 -98
- package/dist/core/reactivity/zen-memo.d.ts +0 -43
- package/dist/core/reactivity/zen-memo.js +0 -100
- package/dist/core/reactivity/zen-ref.d.ts +0 -44
- package/dist/core/reactivity/zen-ref.js +0 -34
- package/dist/core/reactivity/zen-signal.d.ts +0 -48
- package/dist/core/reactivity/zen-signal.js +0 -84
- package/dist/core/reactivity/zen-state.d.ts +0 -35
- package/dist/core/reactivity/zen-state.js +0 -147
- package/dist/core/reactivity/zen-untrack.d.ts +0 -38
- package/dist/core/reactivity/zen-untrack.js +0 -41
- package/dist/css/index.d.ts +0 -73
- package/dist/css/index.js +0 -246
- package/dist/discovery/componentDiscovery.d.ts +0 -42
- package/dist/discovery/componentDiscovery.js +0 -56
- package/dist/discovery/layouts.d.ts +0 -13
- package/dist/discovery/layouts.js +0 -41
- package/dist/errors/compilerError.d.ts +0 -31
- package/dist/errors/compilerError.js +0 -51
- package/dist/finalize/finalizeOutput.d.ts +0 -32
- package/dist/finalize/finalizeOutput.js +0 -62
- package/dist/finalize/generateFinalBundle.d.ts +0 -24
- package/dist/finalize/generateFinalBundle.js +0 -68
- package/dist/index.d.ts +0 -38
- package/dist/index.js +0 -57
- package/dist/ir/types.d.ts +0 -181
- package/dist/ir/types.js +0 -8
- package/dist/output/types.d.ts +0 -30
- package/dist/output/types.js +0 -6
- package/dist/parse/detectMapExpressions.d.ts +0 -45
- package/dist/parse/detectMapExpressions.js +0 -77
- package/dist/parse/parseScript.d.ts +0 -8
- package/dist/parse/parseScript.js +0 -36
- package/dist/parse/parseTemplate.d.ts +0 -11
- package/dist/parse/parseTemplate.js +0 -487
- package/dist/parse/parseZenFile.d.ts +0 -11
- package/dist/parse/parseZenFile.js +0 -50
- package/dist/parse/scriptAnalysis.d.ts +0 -25
- package/dist/parse/scriptAnalysis.js +0 -60
- package/dist/parse/trackLoopContext.d.ts +0 -20
- package/dist/parse/trackLoopContext.js +0 -62
- package/dist/parseZenFile.d.ts +0 -10
- package/dist/parseZenFile.js +0 -55
- package/dist/runtime/analyzeAndEmit.d.ts +0 -20
- package/dist/runtime/analyzeAndEmit.js +0 -70
- package/dist/runtime/build.d.ts +0 -6
- package/dist/runtime/build.js +0 -13
- package/dist/runtime/bundle-generator.d.ts +0 -27
- package/dist/runtime/bundle-generator.js +0 -1438
- package/dist/runtime/client-runtime.d.ts +0 -41
- package/dist/runtime/client-runtime.js +0 -397
- package/dist/runtime/dataExposure.d.ts +0 -52
- package/dist/runtime/dataExposure.js +0 -227
- package/dist/runtime/generateDOM.d.ts +0 -21
- package/dist/runtime/generateDOM.js +0 -194
- package/dist/runtime/generateHydrationBundle.d.ts +0 -15
- package/dist/runtime/generateHydrationBundle.js +0 -399
- package/dist/runtime/hydration.d.ts +0 -53
- package/dist/runtime/hydration.js +0 -271
- package/dist/runtime/navigation.d.ts +0 -58
- package/dist/runtime/navigation.js +0 -372
- package/dist/runtime/serve.d.ts +0 -13
- package/dist/runtime/serve.js +0 -76
- package/dist/runtime/thinRuntime.d.ts +0 -23
- package/dist/runtime/thinRuntime.js +0 -158
- package/dist/runtime/transformIR.d.ts +0 -19
- package/dist/runtime/transformIR.js +0 -285
- package/dist/runtime/wrapExpression.d.ts +0 -24
- package/dist/runtime/wrapExpression.js +0 -76
- package/dist/runtime/wrapExpressionWithLoop.d.ts +0 -17
- package/dist/runtime/wrapExpressionWithLoop.js +0 -75
- package/dist/spa-build.d.ts +0 -26
- package/dist/spa-build.js +0 -857
- package/dist/ssg-build.d.ts +0 -32
- package/dist/ssg-build.js +0 -408
- package/dist/test/analyze-emit.test.d.ts +0 -1
- package/dist/test/analyze-emit.test.js +0 -88
- package/dist/test/bundler-contract.test.d.ts +0 -1
- package/dist/test/bundler-contract.test.js +0 -137
- package/dist/test/compiler-authority.test.d.ts +0 -1
- package/dist/test/compiler-authority.test.js +0 -90
- package/dist/test/component-instance-test.d.ts +0 -1
- package/dist/test/component-instance-test.js +0 -115
- package/dist/test/error-native-bridge.test.d.ts +0 -1
- package/dist/test/error-native-bridge.test.js +0 -51
- package/dist/test/error-serialization.test.d.ts +0 -1
- package/dist/test/error-serialization.test.js +0 -38
- package/dist/test/macro-inlining.test.d.ts +0 -1
- package/dist/test/macro-inlining.test.js +0 -178
- package/dist/test/validate-test.d.ts +0 -6
- package/dist/test/validate-test.js +0 -95
- package/dist/transform/classifyExpression.d.ts +0 -46
- package/dist/transform/classifyExpression.js +0 -359
- package/dist/transform/componentResolver.d.ts +0 -15
- package/dist/transform/componentResolver.js +0 -24
- package/dist/transform/expressionTransformer.d.ts +0 -19
- package/dist/transform/expressionTransformer.js +0 -333
- package/dist/transform/fragmentLowering.d.ts +0 -25
- package/dist/transform/fragmentLowering.js +0 -468
- package/dist/transform/layoutProcessor.d.ts +0 -5
- package/dist/transform/layoutProcessor.js +0 -34
- package/dist/transform/transformTemplate.d.ts +0 -11
- package/dist/transform/transformTemplate.js +0 -33
- package/dist/validate/invariants.d.ts +0 -23
- package/dist/validate/invariants.js +0 -55
package/dist/bundler.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @zenithbuild/core - Page Script Bundler
|
|
3
|
-
*
|
|
4
|
-
* COMPILER-FIRST ARCHITECTURE
|
|
5
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
6
|
-
*
|
|
7
|
-
* This bundler performs ZERO inference. It executes exactly what the compiler specifies.
|
|
8
|
-
*
|
|
9
|
-
* Rules:
|
|
10
|
-
* - If a BundlePlan is provided, bundling MUST occur
|
|
11
|
-
* - If bundling fails, throw a hard error (no fallback)
|
|
12
|
-
* - The bundler never inspects source code for intent
|
|
13
|
-
* - No temp files, no heuristics, no recovery
|
|
14
|
-
*
|
|
15
|
-
* Bundler failure = compiler bug.
|
|
16
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
17
|
-
*/
|
|
18
|
-
import { rolldown } from 'rolldown';
|
|
19
|
-
/**
|
|
20
|
-
* Execute a compiler-emitted BundlePlan
|
|
21
|
-
*
|
|
22
|
-
* This is a PURE PLAN EXECUTOR. It does not:
|
|
23
|
-
* - Inspect source code for imports
|
|
24
|
-
* - Decide whether bundling is needed
|
|
25
|
-
* - Fall back on failure
|
|
26
|
-
* - Use temp files
|
|
27
|
-
*
|
|
28
|
-
* @param plan - Compiler-emitted BundlePlan (must exist; caller must not call if no plan)
|
|
29
|
-
* @throws Error if bundling fails (no fallback, no recovery)
|
|
30
|
-
*/
|
|
31
|
-
export async function bundlePageScript(plan) {
|
|
32
|
-
// Virtual entry module ID
|
|
33
|
-
const VIRTUAL_ENTRY = '\0zenith:entry';
|
|
34
|
-
// Build virtual modules map from plan
|
|
35
|
-
const virtualModules = new Map();
|
|
36
|
-
virtualModules.set(VIRTUAL_ENTRY, plan.entry);
|
|
37
|
-
for (const vm of plan.virtualModules) {
|
|
38
|
-
virtualModules.set(vm.id, vm.code);
|
|
39
|
-
}
|
|
40
|
-
// Execute Rolldown with plan-specified configuration
|
|
41
|
-
// No inference, no heuristics, no semantic analysis
|
|
42
|
-
const bundle = await rolldown({
|
|
43
|
-
input: VIRTUAL_ENTRY,
|
|
44
|
-
platform: plan.platform,
|
|
45
|
-
resolve: {
|
|
46
|
-
modules: plan.resolveRoots
|
|
47
|
-
},
|
|
48
|
-
plugins: [{
|
|
49
|
-
name: 'zenith-virtual',
|
|
50
|
-
resolveId(source) {
|
|
51
|
-
// Virtual modules from plan
|
|
52
|
-
if (virtualModules.has(source)) {
|
|
53
|
-
return { id: source, moduleSideEffects: false };
|
|
54
|
-
}
|
|
55
|
-
// Special case: zenith:content namespace
|
|
56
|
-
if (source === 'zenith:content') {
|
|
57
|
-
return { id: '\0zenith:content', moduleSideEffects: false };
|
|
58
|
-
}
|
|
59
|
-
return null;
|
|
60
|
-
},
|
|
61
|
-
load(id) {
|
|
62
|
-
return virtualModules.get(id) ?? null;
|
|
63
|
-
}
|
|
64
|
-
}],
|
|
65
|
-
// DETERMINISTIC OUTPUT: Disable all semantic optimizations
|
|
66
|
-
// Tree-shaking implies semantic analysis - bundler must not infer
|
|
67
|
-
treeshake: false,
|
|
68
|
-
// HARD FAILURE on unresolved imports - no silent external treatment
|
|
69
|
-
onLog(level, log) {
|
|
70
|
-
if (log.code === 'UNRESOLVED_IMPORT') {
|
|
71
|
-
throw new Error(`[Zenith Bundler] Unresolved import: ${log.message}. ` +
|
|
72
|
-
`This is a compiler error - the BundlePlan references a module that cannot be resolved.`);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
// Generate output with plan-specified format
|
|
77
|
-
const { output } = await bundle.generate({
|
|
78
|
-
format: plan.format
|
|
79
|
-
});
|
|
80
|
-
// Hard failure if no output - this is a compiler bug
|
|
81
|
-
if (!output[0]?.code) {
|
|
82
|
-
throw new Error('[Zenith Bundler] Rolldown produced no output. ' +
|
|
83
|
-
'This is a compiler error - the BundlePlan was invalid or Rolldown failed silently.');
|
|
84
|
-
}
|
|
85
|
-
return output[0].code;
|
|
86
|
-
}
|
|
Binary file
|
|
Binary file
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Core Components
|
|
3
|
-
*
|
|
4
|
-
* Reusable components provided by zenith-core.
|
|
5
|
-
*/
|
|
6
|
-
export declare const CORE_COMPONENTS: {
|
|
7
|
-
readonly ErrorPage: "@zenithbuild/core/components/ErrorPage.zen";
|
|
8
|
-
};
|
|
9
|
-
export declare function getCoreComponentPath(componentName: keyof typeof CORE_COMPONENTS): string;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Core Components
|
|
3
|
-
*
|
|
4
|
-
* Reusable components provided by zenith-core.
|
|
5
|
-
*/
|
|
6
|
-
// Export path constants for component resolution
|
|
7
|
-
export const CORE_COMPONENTS = {
|
|
8
|
-
ErrorPage: '@zenithbuild/core/components/ErrorPage.zen'
|
|
9
|
-
};
|
|
10
|
-
// Component path resolver
|
|
11
|
-
export function getCoreComponentPath(componentName) {
|
|
12
|
-
return CORE_COMPONENTS[componentName];
|
|
13
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zenith Config
|
|
3
|
-
*
|
|
4
|
-
* Public exports for zenith/config
|
|
5
|
-
*
|
|
6
|
-
* Core exports ONLY generic plugin infrastructure.
|
|
7
|
-
* Plugin-specific types are owned by their respective plugins.
|
|
8
|
-
*/
|
|
9
|
-
export { defineConfig } from './types';
|
|
10
|
-
export type { ZenithConfig, ZenithPlugin, PluginContext, PluginData } from './types';
|
|
11
|
-
export { loadZenithConfig, hasZenithConfig } from './loader';
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zenith Config
|
|
3
|
-
*
|
|
4
|
-
* Public exports for zenith/config
|
|
5
|
-
*
|
|
6
|
-
* Core exports ONLY generic plugin infrastructure.
|
|
7
|
-
* Plugin-specific types are owned by their respective plugins.
|
|
8
|
-
*/
|
|
9
|
-
export { defineConfig } from './types';
|
|
10
|
-
export { loadZenithConfig, hasZenithConfig } from './loader';
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zenith Config Loader
|
|
3
|
-
*
|
|
4
|
-
* Loads zenith.config.ts from the project root
|
|
5
|
-
*/
|
|
6
|
-
import type { ZenithConfig } from './types';
|
|
7
|
-
/**
|
|
8
|
-
* Load zenith.config.ts from the project root
|
|
9
|
-
*
|
|
10
|
-
* @param projectRoot - Absolute path to the project root
|
|
11
|
-
* @returns Parsed ZenithConfig or empty config if not found
|
|
12
|
-
*/
|
|
13
|
-
export declare function loadZenithConfig(projectRoot: string): Promise<ZenithConfig>;
|
|
14
|
-
/**
|
|
15
|
-
* Check if a zenith.config.ts exists in the project
|
|
16
|
-
*/
|
|
17
|
-
export declare function hasZenithConfig(projectRoot: string): boolean;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zenith Config Loader
|
|
3
|
-
*
|
|
4
|
-
* Loads zenith.config.ts from the project root
|
|
5
|
-
*/
|
|
6
|
-
import fs from 'node:fs';
|
|
7
|
-
import path from 'node:path';
|
|
8
|
-
/**
|
|
9
|
-
* Load zenith.config.ts from the project root
|
|
10
|
-
*
|
|
11
|
-
* @param projectRoot - Absolute path to the project root
|
|
12
|
-
* @returns Parsed ZenithConfig or empty config if not found
|
|
13
|
-
*/
|
|
14
|
-
export async function loadZenithConfig(projectRoot) {
|
|
15
|
-
// Check for TypeScript config first, then JavaScript
|
|
16
|
-
const configPaths = [
|
|
17
|
-
path.join(projectRoot, 'zenith.config.ts'),
|
|
18
|
-
path.join(projectRoot, 'zenith.config.js'),
|
|
19
|
-
path.join(projectRoot, 'zenith.config.mjs'),
|
|
20
|
-
];
|
|
21
|
-
let configPath = null;
|
|
22
|
-
for (const p of configPaths) {
|
|
23
|
-
if (fs.existsSync(p)) {
|
|
24
|
-
configPath = p;
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
if (!configPath) {
|
|
29
|
-
// No config file found, return empty config
|
|
30
|
-
return { plugins: [] };
|
|
31
|
-
}
|
|
32
|
-
try {
|
|
33
|
-
// Use dynamic import to load the config
|
|
34
|
-
// Bun supports importing TS files directly
|
|
35
|
-
const configModule = await import(configPath);
|
|
36
|
-
const config = configModule.default || configModule;
|
|
37
|
-
// Validate basic structure
|
|
38
|
-
if (typeof config !== 'object' || config === null) {
|
|
39
|
-
console.warn(`[Zenith] Invalid config format in ${configPath}`);
|
|
40
|
-
return { plugins: [] };
|
|
41
|
-
}
|
|
42
|
-
return config;
|
|
43
|
-
}
|
|
44
|
-
catch (error) {
|
|
45
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
46
|
-
console.error(`[Zenith] Failed to load config from ${configPath}:`, message);
|
|
47
|
-
return { plugins: [] };
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Check if a zenith.config.ts exists in the project
|
|
52
|
-
*/
|
|
53
|
-
export function hasZenithConfig(projectRoot) {
|
|
54
|
-
const configPaths = [
|
|
55
|
-
path.join(projectRoot, 'zenith.config.ts'),
|
|
56
|
-
path.join(projectRoot, 'zenith.config.js'),
|
|
57
|
-
path.join(projectRoot, 'zenith.config.mjs'),
|
|
58
|
-
];
|
|
59
|
-
return configPaths.some(p => fs.existsSync(p));
|
|
60
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zenith Config Types
|
|
3
|
-
*
|
|
4
|
-
* Configuration interfaces for zenith.config.ts
|
|
5
|
-
*
|
|
6
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
7
|
-
* HOOK OWNERSHIP RULE (CANONICAL)
|
|
8
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
9
|
-
*
|
|
10
|
-
* Core may ONLY define types that are universally valid in all Zenith applications.
|
|
11
|
-
* Plugin-specific types MUST be owned by their respective plugins.
|
|
12
|
-
*
|
|
13
|
-
* ✅ ALLOWED in Core:
|
|
14
|
-
* - ZenithConfig, ZenithPlugin, PluginContext (generic plugin infrastructure)
|
|
15
|
-
* - Universal lifecycle hooks (onMount, onUnmount)
|
|
16
|
-
* - Reactivity primitives (signal, effect, etc.)
|
|
17
|
-
*
|
|
18
|
-
* ❌ PROHIBITED in Core:
|
|
19
|
-
* - Content plugin types (ContentItem, ContentSourceConfig, etc.)
|
|
20
|
-
* - Router plugin types (RouteState, NavigationGuard, etc.)
|
|
21
|
-
* - Documentation plugin types
|
|
22
|
-
* - Any type that exists only because a plugin exists
|
|
23
|
-
*
|
|
24
|
-
* If removing a plugin would make a type meaningless, that type belongs to the plugin.
|
|
25
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
26
|
-
*/
|
|
27
|
-
import type { CLIBridgeAPI } from '../plugins/bridge';
|
|
28
|
-
/**
|
|
29
|
-
* Generic data record for plugin data exchange
|
|
30
|
-
* Plugins define their own specific types internally
|
|
31
|
-
*/
|
|
32
|
-
export type PluginData = Record<string, unknown[]>;
|
|
33
|
-
/**
|
|
34
|
-
* Context passed to plugins during setup
|
|
35
|
-
*
|
|
36
|
-
* This is intentionally generic - plugins define their own data shapes.
|
|
37
|
-
* Core provides the stage, plugins bring the actors.
|
|
38
|
-
*/
|
|
39
|
-
export interface PluginContext {
|
|
40
|
-
/** Absolute path to project root */
|
|
41
|
-
projectRoot: string;
|
|
42
|
-
/**
|
|
43
|
-
* Set plugin data for the runtime
|
|
44
|
-
*
|
|
45
|
-
* Generic setter - plugins define their own data structures.
|
|
46
|
-
* The runtime stores this data and makes it available to components.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* // Content plugin uses it for content items
|
|
50
|
-
* ctx.setPluginData('content', contentItems);
|
|
51
|
-
*
|
|
52
|
-
* // Analytics plugin uses it for tracking config
|
|
53
|
-
* ctx.setPluginData('analytics', analyticsConfig);
|
|
54
|
-
*/
|
|
55
|
-
setPluginData: (namespace: string, data: unknown[]) => void;
|
|
56
|
-
/** Additional options passed from config */
|
|
57
|
-
options?: Record<string, unknown>;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* A Zenith plugin definition
|
|
61
|
-
*
|
|
62
|
-
* Plugins are self-contained, removable extensions.
|
|
63
|
-
* Core must build and run identically with or without any plugin installed.
|
|
64
|
-
*/
|
|
65
|
-
export interface ZenithPlugin {
|
|
66
|
-
/** Unique plugin name */
|
|
67
|
-
name: string;
|
|
68
|
-
/** Setup function called during initialization */
|
|
69
|
-
setup: (ctx: PluginContext) => void | Promise<void>;
|
|
70
|
-
/** Plugin-specific configuration (preserved for reference) */
|
|
71
|
-
config?: unknown;
|
|
72
|
-
/**
|
|
73
|
-
* Optional CLI registration
|
|
74
|
-
*
|
|
75
|
-
* Plugin receives the CLI bridge API to register namespaced hooks.
|
|
76
|
-
* CLI lifecycle hooks: 'cli:*' (owned by CLI)
|
|
77
|
-
* Plugin hooks: '<namespace>:*' (owned by plugin)
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
* registerCLI(api) {
|
|
81
|
-
* api.on('cli:runtime:collect', (ctx) => {
|
|
82
|
-
* return { namespace: 'myPlugin', payload: ctx.getPluginData('myPlugin') }
|
|
83
|
-
* })
|
|
84
|
-
* }
|
|
85
|
-
*/
|
|
86
|
-
registerCLI?: (api: CLIBridgeAPI) => void;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Zenith configuration object
|
|
90
|
-
*/
|
|
91
|
-
export interface ZenithConfig {
|
|
92
|
-
/** List of plugins to load */
|
|
93
|
-
plugins?: ZenithPlugin[];
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Define a Zenith configuration with full type safety
|
|
97
|
-
*/
|
|
98
|
-
export declare function defineConfig(config: ZenithConfig): ZenithConfig;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zenith Config Types
|
|
3
|
-
*
|
|
4
|
-
* Configuration interfaces for zenith.config.ts
|
|
5
|
-
*
|
|
6
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
7
|
-
* HOOK OWNERSHIP RULE (CANONICAL)
|
|
8
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
9
|
-
*
|
|
10
|
-
* Core may ONLY define types that are universally valid in all Zenith applications.
|
|
11
|
-
* Plugin-specific types MUST be owned by their respective plugins.
|
|
12
|
-
*
|
|
13
|
-
* ✅ ALLOWED in Core:
|
|
14
|
-
* - ZenithConfig, ZenithPlugin, PluginContext (generic plugin infrastructure)
|
|
15
|
-
* - Universal lifecycle hooks (onMount, onUnmount)
|
|
16
|
-
* - Reactivity primitives (signal, effect, etc.)
|
|
17
|
-
*
|
|
18
|
-
* ❌ PROHIBITED in Core:
|
|
19
|
-
* - Content plugin types (ContentItem, ContentSourceConfig, etc.)
|
|
20
|
-
* - Router plugin types (RouteState, NavigationGuard, etc.)
|
|
21
|
-
* - Documentation plugin types
|
|
22
|
-
* - Any type that exists only because a plugin exists
|
|
23
|
-
*
|
|
24
|
-
* If removing a plugin would make a type meaningless, that type belongs to the plugin.
|
|
25
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
26
|
-
*/
|
|
27
|
-
/**
|
|
28
|
-
* Define a Zenith configuration with full type safety
|
|
29
|
-
*/
|
|
30
|
-
export function defineConfig(config) {
|
|
31
|
-
return config;
|
|
32
|
-
}
|
package/dist/core/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zenith Compiler Core Modules
|
|
3
|
-
*/
|
|
4
|
-
export { loadZenithConfig } from './config/loader';
|
|
5
|
-
export { PluginRegistry, createPluginContext, getPluginDataByNamespace } from './plugins/registry';
|
|
6
|
-
export { createBridgeAPI, runPluginHooks, collectHookReturns, buildRuntimeEnvelope, clearHooks } from './plugins/bridge';
|
|
7
|
-
export type { HookContext } from './plugins/bridge';
|
package/dist/core/index.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zenith Compiler Core Modules
|
|
3
|
-
*/
|
|
4
|
-
export { loadZenithConfig } from './config/loader';
|
|
5
|
-
export { PluginRegistry, createPluginContext, getPluginDataByNamespace } from './plugins/registry';
|
|
6
|
-
export { createBridgeAPI, runPluginHooks, collectHookReturns, buildRuntimeEnvelope, clearHooks } from './plugins/bridge';
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zenith Lifecycle Hooks
|
|
3
|
-
*
|
|
4
|
-
* This module exports lifecycle hooks for component mount/unmount events.
|
|
5
|
-
* These are effect wrappers that integrate with the component lifecycle system.
|
|
6
|
-
*
|
|
7
|
-
* Exports both explicit `zen*` names (internal) and clean aliases (public DX).
|
|
8
|
-
*/
|
|
9
|
-
import { zenOnMount as _zenOnMount, triggerMount, triggerUnmount, getIsMounted, resetMountState, type MountCallback } from './zen-mount';
|
|
10
|
-
import { zenOnUnmount as _zenOnUnmount, executeUnmountCallbacks, getUnmountCallbackCount, resetUnmountState, type UnmountCallback } from './zen-unmount';
|
|
11
|
-
export declare const zenOnMount: typeof _zenOnMount;
|
|
12
|
-
export declare const zenOnUnmount: typeof _zenOnUnmount;
|
|
13
|
-
export { triggerMount, triggerUnmount, getIsMounted, resetMountState, executeUnmountCallbacks, getUnmountCallbackCount, resetUnmountState };
|
|
14
|
-
export type { MountCallback, UnmountCallback };
|
|
15
|
-
export declare const onMount: typeof _zenOnMount;
|
|
16
|
-
export declare const onUnmount: typeof _zenOnUnmount;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zenith Lifecycle Hooks
|
|
3
|
-
*
|
|
4
|
-
* This module exports lifecycle hooks for component mount/unmount events.
|
|
5
|
-
* These are effect wrappers that integrate with the component lifecycle system.
|
|
6
|
-
*
|
|
7
|
-
* Exports both explicit `zen*` names (internal) and clean aliases (public DX).
|
|
8
|
-
*/
|
|
9
|
-
// Import lifecycle hooks
|
|
10
|
-
import { zenOnMount as _zenOnMount, triggerMount, triggerUnmount, getIsMounted, resetMountState } from './zen-mount';
|
|
11
|
-
import { zenOnUnmount as _zenOnUnmount, executeUnmountCallbacks, getUnmountCallbackCount, resetUnmountState } from './zen-unmount';
|
|
12
|
-
// Re-export with explicit names
|
|
13
|
-
export const zenOnMount = _zenOnMount;
|
|
14
|
-
export const zenOnUnmount = _zenOnUnmount;
|
|
15
|
-
// Re-export utilities
|
|
16
|
-
export { triggerMount, triggerUnmount, getIsMounted, resetMountState, executeUnmountCallbacks, getUnmountCallbackCount, resetUnmountState };
|
|
17
|
-
// Public DX aliases - clean names
|
|
18
|
-
export const onMount = _zenOnMount;
|
|
19
|
-
export const onUnmount = _zenOnUnmount;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zenith OnMount - Post-Mount Lifecycle Hook
|
|
3
|
-
*
|
|
4
|
-
* Registers a callback to run after a component's DOM is inserted.
|
|
5
|
-
* This is an effect wrapper that defers execution until the mount phase.
|
|
6
|
-
*
|
|
7
|
-
* Features:
|
|
8
|
-
* - Runs after DOM is available
|
|
9
|
-
* - Only runs once per mount
|
|
10
|
-
* - Supports cleanup function return
|
|
11
|
-
* - Works with component lifecycle system
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* zenOnMount(() => {
|
|
16
|
-
* console.log('Component mounted!')
|
|
17
|
-
* const el = document.querySelector('.my-element')
|
|
18
|
-
*
|
|
19
|
-
* // Optional cleanup - runs on unmount
|
|
20
|
-
* return () => {
|
|
21
|
-
* console.log('Component will unmount')
|
|
22
|
-
* }
|
|
23
|
-
* })
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* Note: This hook registers callbacks that will be executed by the
|
|
27
|
-
* component lifecycle system. If no mount scheduler is active,
|
|
28
|
-
* callbacks are queued for later execution.
|
|
29
|
-
*/
|
|
30
|
-
/**
|
|
31
|
-
* Mount callback type - can optionally return a cleanup function
|
|
32
|
-
*/
|
|
33
|
-
export type MountCallback = () => void | (() => void);
|
|
34
|
-
/**
|
|
35
|
-
* Register a callback to run after component mount
|
|
36
|
-
*
|
|
37
|
-
* @param callback - Function to run after mount (can return cleanup function)
|
|
38
|
-
* @returns Dispose function to cancel the mount callback
|
|
39
|
-
*/
|
|
40
|
-
export declare function zenOnMount(callback: MountCallback): () => void;
|
|
41
|
-
/**
|
|
42
|
-
* Trigger mount phase - called by component lifecycle system
|
|
43
|
-
* Executes all pending mount callbacks
|
|
44
|
-
*
|
|
45
|
-
* @internal
|
|
46
|
-
*/
|
|
47
|
-
export declare function triggerMount(): void;
|
|
48
|
-
/**
|
|
49
|
-
* Trigger unmount phase - called by component lifecycle system
|
|
50
|
-
* Runs cleanup functions for all active mount hooks
|
|
51
|
-
*
|
|
52
|
-
* @internal
|
|
53
|
-
*/
|
|
54
|
-
export declare function triggerUnmount(): void;
|
|
55
|
-
/**
|
|
56
|
-
* Check if currently in mounted state
|
|
57
|
-
*
|
|
58
|
-
* @internal
|
|
59
|
-
*/
|
|
60
|
-
export declare function getIsMounted(): boolean;
|
|
61
|
-
/**
|
|
62
|
-
* Reset mount state - for testing purposes
|
|
63
|
-
*
|
|
64
|
-
* @internal
|
|
65
|
-
*/
|
|
66
|
-
export declare function resetMountState(): void;
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zenith OnMount - Post-Mount Lifecycle Hook
|
|
3
|
-
*
|
|
4
|
-
* Registers a callback to run after a component's DOM is inserted.
|
|
5
|
-
* This is an effect wrapper that defers execution until the mount phase.
|
|
6
|
-
*
|
|
7
|
-
* Features:
|
|
8
|
-
* - Runs after DOM is available
|
|
9
|
-
* - Only runs once per mount
|
|
10
|
-
* - Supports cleanup function return
|
|
11
|
-
* - Works with component lifecycle system
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* zenOnMount(() => {
|
|
16
|
-
* console.log('Component mounted!')
|
|
17
|
-
* const el = document.querySelector('.my-element')
|
|
18
|
-
*
|
|
19
|
-
* // Optional cleanup - runs on unmount
|
|
20
|
-
* return () => {
|
|
21
|
-
* console.log('Component will unmount')
|
|
22
|
-
* }
|
|
23
|
-
* })
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* Note: This hook registers callbacks that will be executed by the
|
|
27
|
-
* component lifecycle system. If no mount scheduler is active,
|
|
28
|
-
* callbacks are queued for later execution.
|
|
29
|
-
*/
|
|
30
|
-
/**
|
|
31
|
-
* Queue of pending mount callbacks
|
|
32
|
-
* These are registered but not yet executed because mount hasn't occurred
|
|
33
|
-
*/
|
|
34
|
-
const pendingMountCallbacks = [];
|
|
35
|
-
/**
|
|
36
|
-
* Currently active mount hooks (for cleanup on unmount)
|
|
37
|
-
*/
|
|
38
|
-
const activeMountHooks = new Set();
|
|
39
|
-
/**
|
|
40
|
-
* Flag indicating whether we're in a mounted state
|
|
41
|
-
* This is controlled by the component lifecycle system
|
|
42
|
-
*/
|
|
43
|
-
let isMounted = false;
|
|
44
|
-
/**
|
|
45
|
-
* Register a callback to run after component mount
|
|
46
|
-
*
|
|
47
|
-
* @param callback - Function to run after mount (can return cleanup function)
|
|
48
|
-
* @returns Dispose function to cancel the mount callback
|
|
49
|
-
*/
|
|
50
|
-
export function zenOnMount(callback) {
|
|
51
|
-
const state = {
|
|
52
|
-
callback,
|
|
53
|
-
cleanup: null,
|
|
54
|
-
mounted: false
|
|
55
|
-
};
|
|
56
|
-
if (isMounted) {
|
|
57
|
-
// Already mounted - run immediately
|
|
58
|
-
executeMountCallback(state);
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
// Queue for later execution
|
|
62
|
-
pendingMountCallbacks.push(state);
|
|
63
|
-
}
|
|
64
|
-
activeMountHooks.add(state);
|
|
65
|
-
// Return dispose function
|
|
66
|
-
return () => {
|
|
67
|
-
// Remove from pending if not yet executed
|
|
68
|
-
const pendingIndex = pendingMountCallbacks.indexOf(state);
|
|
69
|
-
if (pendingIndex !== -1) {
|
|
70
|
-
pendingMountCallbacks.splice(pendingIndex, 1);
|
|
71
|
-
}
|
|
72
|
-
// Run cleanup if already mounted
|
|
73
|
-
if (state.mounted && state.cleanup) {
|
|
74
|
-
state.cleanup();
|
|
75
|
-
state.cleanup = null;
|
|
76
|
-
}
|
|
77
|
-
activeMountHooks.delete(state);
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Execute a mount callback
|
|
82
|
-
*/
|
|
83
|
-
function executeMountCallback(state) {
|
|
84
|
-
if (state.mounted)
|
|
85
|
-
return;
|
|
86
|
-
state.mounted = true;
|
|
87
|
-
try {
|
|
88
|
-
const result = state.callback();
|
|
89
|
-
if (typeof result === 'function') {
|
|
90
|
-
state.cleanup = result;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
catch (error) {
|
|
94
|
-
console.error('[Zenith] Error in onMount callback:', error);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Trigger mount phase - called by component lifecycle system
|
|
99
|
-
* Executes all pending mount callbacks
|
|
100
|
-
*
|
|
101
|
-
* @internal
|
|
102
|
-
*/
|
|
103
|
-
export function triggerMount() {
|
|
104
|
-
isMounted = true;
|
|
105
|
-
// Execute all pending callbacks
|
|
106
|
-
const callbacks = [...pendingMountCallbacks];
|
|
107
|
-
pendingMountCallbacks.length = 0;
|
|
108
|
-
for (const state of callbacks) {
|
|
109
|
-
executeMountCallback(state);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Trigger unmount phase - called by component lifecycle system
|
|
114
|
-
* Runs cleanup functions for all active mount hooks
|
|
115
|
-
*
|
|
116
|
-
* @internal
|
|
117
|
-
*/
|
|
118
|
-
export function triggerUnmount() {
|
|
119
|
-
isMounted = false;
|
|
120
|
-
// Run all cleanup functions
|
|
121
|
-
for (const state of activeMountHooks) {
|
|
122
|
-
if (state.cleanup) {
|
|
123
|
-
try {
|
|
124
|
-
state.cleanup();
|
|
125
|
-
}
|
|
126
|
-
catch (error) {
|
|
127
|
-
console.error('[Zenith] Error in onMount cleanup:', error);
|
|
128
|
-
}
|
|
129
|
-
state.cleanup = null;
|
|
130
|
-
}
|
|
131
|
-
state.mounted = false;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Check if currently in mounted state
|
|
136
|
-
*
|
|
137
|
-
* @internal
|
|
138
|
-
*/
|
|
139
|
-
export function getIsMounted() {
|
|
140
|
-
return isMounted;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Reset mount state - for testing purposes
|
|
144
|
-
*
|
|
145
|
-
* @internal
|
|
146
|
-
*/
|
|
147
|
-
export function resetMountState() {
|
|
148
|
-
isMounted = false;
|
|
149
|
-
pendingMountCallbacks.length = 0;
|
|
150
|
-
activeMountHooks.clear();
|
|
151
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zenith OnUnmount - Pre-Unmount Lifecycle Hook
|
|
3
|
-
*
|
|
4
|
-
* Registers a cleanup callback to run before a component is disposed.
|
|
5
|
-
* Useful for cleaning up subscriptions, timers, event listeners, etc.
|
|
6
|
-
*
|
|
7
|
-
* Features:
|
|
8
|
-
* - Runs before component is removed from DOM
|
|
9
|
-
* - Can register multiple callbacks
|
|
10
|
-
* - Callbacks run in registration order
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* zenOnUnmount(() => {
|
|
15
|
-
* console.log('Cleaning up...')
|
|
16
|
-
* subscription.unsubscribe()
|
|
17
|
-
* clearInterval(timerId)
|
|
18
|
-
* })
|
|
19
|
-
* ```
|
|
20
|
-
*
|
|
21
|
-
* Note: This hook registers callbacks that will be executed by the
|
|
22
|
-
* component lifecycle system when the component is disposed.
|
|
23
|
-
*/
|
|
24
|
-
/**
|
|
25
|
-
* Unmount callback type
|
|
26
|
-
*/
|
|
27
|
-
export type UnmountCallback = () => void;
|
|
28
|
-
/**
|
|
29
|
-
* Register a callback to run before component unmount
|
|
30
|
-
*
|
|
31
|
-
* @param callback - Function to run before unmount
|
|
32
|
-
* @returns Dispose function to cancel the unmount callback
|
|
33
|
-
*/
|
|
34
|
-
export declare function zenOnUnmount(callback: UnmountCallback): () => void;
|
|
35
|
-
/**
|
|
36
|
-
* Execute all unmount callbacks
|
|
37
|
-
* Called by the component lifecycle system before disposal
|
|
38
|
-
*
|
|
39
|
-
* @internal
|
|
40
|
-
*/
|
|
41
|
-
export declare function executeUnmountCallbacks(): void;
|
|
42
|
-
/**
|
|
43
|
-
* Get count of registered unmount callbacks
|
|
44
|
-
* Useful for testing
|
|
45
|
-
*
|
|
46
|
-
* @internal
|
|
47
|
-
*/
|
|
48
|
-
export declare function getUnmountCallbackCount(): number;
|
|
49
|
-
/**
|
|
50
|
-
* Reset unmount state - for testing purposes
|
|
51
|
-
*
|
|
52
|
-
* @internal
|
|
53
|
-
*/
|
|
54
|
-
export declare function resetUnmountState(): void;
|