Coralite v0.34.0 Released
Coralite v0.34.0 introduces a major redesign of the core component definition and state management APIs. This release transitions the framework to the Flat Options API, replacing properties with a unified reactive state object. It also adds robust build-time error reporting and improves client runtime performance and safety.
The Flat Options API and Unified State #
This release deprecates the properties-based state management model in favor of the new Flat Options API. Component configurations now follow a strict structure: { attributes, data, getters, slots, script }. This unifies state, attributes, and getters under a single reactive state proxy.
Attributes support build-time validation and primitive coercion (Number, Boolean, and String). A dedicated data() block defines the boundary for server-to-client data serialization. During build, code stripping automatically removes the data() method and any Node.js imports from the client bundle to minimize payload sizes.
defineComponent({
attributes: {
userId: String,
initialCount: {
type: Number,
default: 0
}
},
data() {
return {
clicks: 0
};
},
getters: {
totalClicks(state) {
return state.initialCount + state.clicks;
}
},
script({ state, refs }) {
// Client-side interactions
state.clicks++;
}
});
Read-Only Getters and Dual-Proxy Reactivity #
To enforce unidirectional data flow, getters now enforce strictly read-only access to state. The core engine implements this with a dual-proxy system: a reactive proxy on the client and a read-only proxy during server evaluation.
Additionally, async getters now receive an AbortSignal. This provides built-in async race protection, enabling the runtime to discard stale requests if a newer state transition begins before the previous promise resolves.
Improved Error Reporting with CoraliteError #
To simplify debugging, the new CoraliteError class captures comprehensive component context during build failures. The class automatically wraps evaluation errors in _evaluateProduction and _evaluateDevelopment, providing detailed context including:
- Component ID
- Instance ID
- Source file path
- Page path
This information is processed and logged by displayError within coralite-scripts to help pinpoint build issues quickly.
Breaking Changes #
- Unified State Mechanism: The properties API has been removed. All components must be updated to use the Flat Options API format.
- Enforced Read-Only Getters: Getters now receive a read-only proxy. Attempting to mutate state properties inside a getter will throw a runtime error.
- Updated script Context Arguments: The client-side
scriptfunction signature has changed. Context arguments (such asrefsand plugin context) are now grouped into a single context object.
How to Upgrade #
To upgrade to the latest version, update your project dependencies:
npm install coralite@0.34.0
npm install coralite-scripts@0.34.0
