@damarkuncoro/meta-architecture-style-engine 0.1.1 β 0.1.3
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/README.md +279 -885
- package/lib/cjs/cli/index.js +1747 -61
- package/lib/cjs/cli/index.js.map +1 -1
- package/lib/cjs/index.d.ts +117 -65
- package/lib/cjs/index.js +1382 -41
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/integration/postcss/index.d.ts +41 -0
- package/lib/cjs/integration/postcss/index.js +296 -0
- package/lib/cjs/integration/postcss/index.js.map +1 -0
- package/lib/cjs/integration/tailwind/index.d.ts +40 -0
- package/lib/cjs/integration/tailwind/index.js +192 -0
- package/lib/cjs/integration/tailwind/index.js.map +1 -0
- package/lib/cjs/types-HxpHKBfo.d.ts +58 -0
- package/lib/esm/cli/index.js +1753 -61
- package/lib/esm/cli/index.js.map +1 -1
- package/lib/esm/index.d.mts +117 -65
- package/lib/esm/index.js +1379 -41
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/integration/postcss/index.d.mts +41 -0
- package/lib/esm/integration/postcss/index.js +269 -0
- package/lib/esm/integration/postcss/index.js.map +1 -0
- package/lib/esm/integration/tailwind/index.d.mts +40 -0
- package/lib/esm/integration/tailwind/index.js +165 -0
- package/lib/esm/integration/tailwind/index.js.map +1 -0
- package/lib/esm/types-HxpHKBfo.d.mts +58 -0
- package/package.json +29 -6
package/README.md
CHANGED
|
@@ -1,831 +1,364 @@
|
|
|
1
|
-
# Meta Architecture Style Engine
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
## π― Overview
|
|
47
|
-
|
|
48
|
-
**MASE (Meta Architecture Style Engine)** is a powerful style governance and runtime engine designed for Meta Architecture. Unlike traditional styling frameworks, MASE treats styling as a constitutional system where every style decision is validated against a set of rules and constraints.
|
|
49
|
-
|
|
50
|
-
MASE enforces design system rules, manages tokens, and compiles style contracts into various output formats (CSS, React Native, PDF) through a sophisticated governance system inspired by the Trias Politica principle.
|
|
51
|
-
|
|
52
|
-
### What Makes MASE Different?
|
|
53
|
-
|
|
54
|
-
| Traditional Approach | MASE Approach |
|
|
55
|
-
| :--- | :--- |
|
|
56
|
-
| **Utility Classes** | **Style Contracts** (Legal Articles) |
|
|
57
|
-
| **Config Files** | **Constitutions** (Laws) |
|
|
58
|
-
| **Prefix Variants** (`hover:`) | **Contextual Laws** |
|
|
59
|
-
| **Compilers** | **Style Resolution Engine** (Judiciary) |
|
|
60
|
-
| **CSS Output** | **Canonical Style Graph** + **Materializer** |
|
|
61
|
-
| **Best Practices** | **Enforced Governance** |
|
|
62
|
-
|
|
63
|
-
---
|
|
64
|
-
|
|
65
|
-
## π‘ Philosophy
|
|
66
|
-
|
|
67
|
-
MASE is not just another "Tailwind Killer" or styling framework. It's a **Constitutional Styling System** β a governance system for styling where:
|
|
68
|
-
|
|
69
|
-
> **"Style is not just visual, but a legal decision that must be validated."**
|
|
70
|
-
|
|
71
|
-
### Core Principles
|
|
72
|
-
|
|
73
|
-
1. **Separation of Concerns**: Complete separation between specification, validation, and materialization
|
|
74
|
-
2. **Type Safety**: Every style decision is validated at compile-time and runtime
|
|
75
|
-
3. **Platform Agnostic**: The core engine doesn't know about CSS, React Native, or any specific platform
|
|
76
|
-
4. **Immutable Truth**: Style contracts and token registries are immutable sources of truth
|
|
77
|
-
5. **Audit Trail**: Every style resolution can be traced back to its constitutional origin
|
|
78
|
-
|
|
79
|
-
---
|
|
80
|
-
|
|
81
|
-
## β¨ Key Features
|
|
82
|
-
|
|
83
|
-
### ποΈ Style Governance
|
|
84
|
-
- **Constitution-based Rules**: Define what's legal in your design system
|
|
85
|
-
- **Domain Taxonomy**: Organize rules by semantic domains (Layout, Typography, Interaction)
|
|
86
|
-
- **Token Registry**: Centralized management of design tokens
|
|
87
|
-
- **Violation Detection**: Automatic detection of style violations with educational error messages
|
|
88
|
-
|
|
89
|
-
### βοΈ Runtime Style Resolution
|
|
90
|
-
- **StyleProvider**: React context provider for theme and device context
|
|
91
|
-
- **StyleContract**: Type-safe style contracts with validation
|
|
92
|
-
- **Dynamic Resolution**: Context-aware style resolution based on theme, device, and platform
|
|
93
|
-
- **Performance Optimized**: Sub-5ms resolution per component
|
|
94
|
-
|
|
95
|
-
### π¨ Multi-Platform Support
|
|
96
|
-
- **CSS Materializer**: Generate optimized CSS for web applications
|
|
97
|
-
- **React Native Materializer**: Generate StyleSheet for native applications
|
|
98
|
-
- **PDF Materializer**: Generate render instructions for PDF generation
|
|
99
|
-
- **Extensible**: Easy to add custom materializers for any platform
|
|
100
|
-
|
|
101
|
-
### π Contract DSL
|
|
102
|
-
- **Declarative Syntax**: Define style contracts using a specialized DSL
|
|
103
|
-
- **Type-Safe**: Compile-time validation of contract definitions
|
|
104
|
-
- **Context-Aware**: Define responsive and state-based styling rules
|
|
105
|
-
- **Theme Support**: Built-in support for light/dark themes
|
|
106
|
-
|
|
107
|
-
### π§ Developer Experience
|
|
108
|
-
- **CLI Tools**: Command-line interface for validation, compilation, and generation
|
|
109
|
-
- **TypeScript Support**: Full TypeScript support with type definitions
|
|
110
|
-
- **Dual Build**: Supports both ESM and CJS modules
|
|
111
|
-
- **Zero-Dependency Testing**: Uses Node.js native test runner for lightweight and fast testing
|
|
112
|
-
- **Hot Reload**: Watch mode for development
|
|
113
|
-
|
|
114
|
-
---
|
|
115
|
-
|
|
116
|
-
## ποΈ Architecture
|
|
117
|
-
|
|
118
|
-
MASE implements the **Trias Politica** principle, separating styling into three independent bodies:
|
|
119
|
-
|
|
120
|
-
### 1. The Constitution (Spec Layer)
|
|
121
|
-
The **Written Law** that defines what's legal in the design system universe.
|
|
122
|
-
|
|
123
|
-
- **Semantic Namespace**: Universal language (e.g., `background.intent.primary`)
|
|
124
|
-
- **Domain Taxonomy**: Legal area groupings (Layout, Typography, Interaction)
|
|
125
|
-
- **Token Registry**: The "currency" of the nation (atomic values)
|
|
126
|
-
|
|
127
|
-
```typescript
|
|
128
|
-
// Example Constitution
|
|
129
|
-
const buttonConstitution = {
|
|
130
|
-
domain: 'interaction',
|
|
131
|
-
rules: {
|
|
132
|
-
intent: {
|
|
133
|
-
allows: ['color.primary', 'color.secondary'],
|
|
134
|
-
default: 'color.primary'
|
|
135
|
-
},
|
|
136
|
-
padding: {
|
|
137
|
-
allows: ['space.sm', 'space.md', 'space.lg'],
|
|
138
|
-
default: 'space.md'
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
### 2. The Judiciary (Style Resolution Engine - SRE)
|
|
145
|
-
The **Judicial Body (Judge)** that validates style contracts.
|
|
146
|
-
|
|
147
|
-
- **Responsibility**: Accepts `StyleContract` and `Context`, decides if valid or violates constitution
|
|
148
|
-
- **Characteristics**:
|
|
149
|
-
- β Doesn't know CSS
|
|
150
|
-
- β Doesn't know Platform (Web/Native)
|
|
151
|
-
- β
Only knows **Legal vs Illegal**
|
|
152
|
-
- **Output**: `StyleResolutionResult` (Resolved Node or Violation Verdict)
|
|
153
|
-
|
|
154
|
-
```typescript
|
|
155
|
-
// Example Resolution
|
|
156
|
-
const result = engine.resolve(contract, constitution, context);
|
|
157
|
-
// Returns: { valid: true, className: 'bg-primary p-md' }
|
|
158
|
-
// Or: { valid: false, violations: [...] }
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
### 3. The Executive (Style Materialization Engine - SME)
|
|
162
|
-
The **Executive Body (Executor)** that executes judicial decisions into physical reality.
|
|
163
|
-
|
|
164
|
-
- **Responsibility**: Execute judicial decisions into actual styles
|
|
165
|
-
- **Plugin System**:
|
|
166
|
-
- **CSS Materializer**: Converts decisions to CSS (Web)
|
|
167
|
-
- **Native Materializer**: Converts decisions to StyleSheet (React Native)
|
|
168
|
-
- **PDF/Canvas**: Converts decisions to render instructions
|
|
169
|
-
|
|
170
|
-
```typescript
|
|
171
|
-
// Example Materialization
|
|
172
|
-
const cssMaterializer = new CSSMaterializer();
|
|
173
|
-
const css = cssMaterializer.materialize(resolvedStyle, context);
|
|
174
|
-
// Returns: ".button { background: #007bff; padding: 1rem; }"
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
### Architecture Diagram
|
|
178
|
-
|
|
179
|
-
```
|
|
180
|
-
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
181
|
-
β MASE Architecture β
|
|
182
|
-
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
|
|
183
|
-
β β
|
|
184
|
-
β ββββββββββββββββββββ ββββββββββββββββββββ β
|
|
185
|
-
β β Constitution βββββββΆβ Judiciary β β
|
|
186
|
-
β β (Spec Layer) β β (SRE) β β
|
|
187
|
-
β β β β β β
|
|
188
|
-
β β β’ Semantic NS β β β’ Validation β β
|
|
189
|
-
β β β’ Domain Tax β β β’ Resolution β β
|
|
190
|
-
β β β’ Token Reg β β β’ Violation β β
|
|
191
|
-
β ββββββββββββββββββββ ββββββββββ¬ββββββββββ β
|
|
192
|
-
β β β
|
|
193
|
-
β βΌ β
|
|
194
|
-
β ββββββββββββββββββββ β
|
|
195
|
-
β β Executive β β
|
|
196
|
-
β β (SME) β β
|
|
197
|
-
β β β β
|
|
198
|
-
β β β’ CSS Mat β β
|
|
199
|
-
β β β’ RN Mat β β
|
|
200
|
-
β β β’ PDF Mat β β
|
|
201
|
-
β ββββββββββββββββββββ β
|
|
202
|
-
β β
|
|
203
|
-
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
---
|
|
1
|
+
# MASE - Meta Architecture Style Engine
|
|
2
|
+
|
|
3
|
+
[](LICENSE)
|
|
4
|
+
[](https://www.typescriptlang.org/)
|
|
5
|
+
[]()
|
|
6
|
+
[](https://github.com/damarkuncoro/meta-architecture-style-engine)
|
|
7
|
+
|
|
8
|
+
A comprehensive, theme-aware styling engine for modern web applications. MASE provides atomic CSS utilities, design token management, and multi-platform materialization with full TypeScript support.
|
|
9
|
+
|
|
10
|
+
## π Features
|
|
11
|
+
|
|
12
|
+
### Core Capabilities
|
|
13
|
+
- **700+ Atomic CSS Utilities** - Complete coverage of all modern CSS properties
|
|
14
|
+
- **Design Token System** - Centralized token management with theme support
|
|
15
|
+
- **Multi-Platform Materialization** - Generate styles for Web, React Native, PDF, and more
|
|
16
|
+
- **Constitutional Styling** - Enforce design system rules and governance
|
|
17
|
+
- **Dark Mode Support** - Automatic theme switching with CSS variables
|
|
18
|
+
- **Full TypeScript Support** - Type-safe development with comprehensive type definitions
|
|
19
|
+
- **Style Governance** - Built-in validation and compliance checking
|
|
20
|
+
- **Performance Optimization** - Caching and efficient style resolution
|
|
21
|
+
|
|
22
|
+
### Integration Options
|
|
23
|
+
- **PostCSS Plugin** - Automatic CSS variable generation
|
|
24
|
+
- **Atomic CSS Generator** - Utility-first approach similar to Tailwind
|
|
25
|
+
- **Tailwind Preset** - Seamless integration with existing Tailwind projects
|
|
26
|
+
- **CSS-in-JS** - Support for styled-components, emotion, and more
|
|
27
|
+
- **React Integration** - React Provider and hooks for runtime styling
|
|
28
|
+
|
|
29
|
+
### Specialized Handlers
|
|
30
|
+
- **Layout** - Display, position, visibility, z-index, overflow, object-fit
|
|
31
|
+
- **Flexbox** - Complete flexbox utilities with justify/align support
|
|
32
|
+
- **Grid** - Full CSS Grid support with template columns/rows
|
|
33
|
+
- **Typography** - Font size, weight, line-height, text alignment
|
|
34
|
+
- **Color** - Background, text, and border colors
|
|
35
|
+
- **Effects** - Shadows, border radius, opacity
|
|
36
|
+
- **Background** - Background image, position, repeat, size, gradients
|
|
37
|
+
- **Border** - Border radius, width, color, style, outline
|
|
38
|
+
- **Transform** - Scale, rotate, translate, skew, perspective
|
|
39
|
+
- **Transition** - Transition properties, timing functions, animations
|
|
40
|
+
- **Interactivity** - Cursor, pointer events, resize, scroll behavior
|
|
41
|
+
- **Tables** - Border collapse, spacing, layout, caption side
|
|
42
|
+
- **SVG** - Fill, stroke, stroke width
|
|
43
|
+
- **Accessibility** - Forced color adjust, screen reader utilities, focus states
|
|
44
|
+
- **Filters** - Blur, brightness, contrast, drop-shadow, grayscale, hue-rotate, invert, saturate, sepia, backdrop-filter
|
|
207
45
|
|
|
208
46
|
## π¦ Installation
|
|
209
47
|
|
|
210
|
-
### Install the Package
|
|
211
|
-
|
|
212
48
|
```bash
|
|
213
49
|
npm install @damarkuncoro/meta-architecture-style-engine
|
|
214
50
|
```
|
|
215
51
|
|
|
216
|
-
###
|
|
52
|
+
### Peer Dependencies
|
|
217
53
|
|
|
218
54
|
```bash
|
|
219
|
-
npm install
|
|
55
|
+
npm install @damarkuncoro/meta-architecture@^2.0.4 react@>=18.0.0 postcss@^8.0.0
|
|
220
56
|
```
|
|
221
57
|
|
|
222
|
-
|
|
58
|
+
## π― Quick Start
|
|
223
59
|
|
|
224
|
-
|
|
60
|
+
### Option 1: PostCSS Plugin (Recommended)
|
|
225
61
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
62
|
+
**postcss.config.js**
|
|
63
|
+
```javascript
|
|
64
|
+
export default {
|
|
65
|
+
plugins: [
|
|
66
|
+
require('@damarkuncoro/meta-architecture-style-engine/postcss')({
|
|
67
|
+
prefix: '--',
|
|
68
|
+
rootSelector: ':root',
|
|
69
|
+
generateDarkMode: true,
|
|
70
|
+
darkModeAttribute: 'data-theme="dark"'
|
|
71
|
+
})
|
|
72
|
+
]
|
|
232
73
|
}
|
|
233
74
|
```
|
|
234
75
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
Get started with MASE in 5 minutes.
|
|
240
|
-
|
|
241
|
-
### Step 1: Create a Contract File
|
|
242
|
-
|
|
243
|
-
Create a file named `Button.contract.dsl`:
|
|
76
|
+
**styles.css**
|
|
77
|
+
```css
|
|
78
|
+
/* MASE CSS variables are automatically injected */
|
|
244
79
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
intent {
|
|
250
|
-
allows: [color.primary, color.secondary]
|
|
251
|
-
default: color.primary
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
padding {
|
|
255
|
-
allows: [space.sm, space.md, space.lg]
|
|
256
|
-
default: space.md
|
|
257
|
-
}
|
|
80
|
+
body {
|
|
81
|
+
font-family: system-ui, sans-serif;
|
|
82
|
+
color: var(--color-text-primary);
|
|
83
|
+
background-color: var(--color-background);
|
|
258
84
|
}
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
### Step 2: Validate Your Contract
|
|
262
85
|
|
|
263
|
-
|
|
264
|
-
|
|
86
|
+
.button {
|
|
87
|
+
background-color: var(--color-primary);
|
|
88
|
+
color: var(--color-white);
|
|
89
|
+
padding: var(--space-md);
|
|
90
|
+
border-radius: var(--radius-md);
|
|
91
|
+
}
|
|
265
92
|
```
|
|
266
93
|
|
|
267
|
-
|
|
268
|
-
```
|
|
269
|
-
β
Contract is valid!
|
|
270
|
-
```
|
|
94
|
+
### Option 2: Atomic CSS Generator
|
|
271
95
|
|
|
272
|
-
|
|
96
|
+
```typescript
|
|
97
|
+
import { AtomicCSSGenerator } from '@damarkuncoro/meta-architecture-style-engine';
|
|
98
|
+
import { TOKENS } from '@damarkuncoro/meta-architecture-style-engine';
|
|
99
|
+
|
|
100
|
+
const generator = new AtomicCSSGenerator();
|
|
101
|
+
const css = generator.generate(TOKENS, {
|
|
102
|
+
prefix: 'mase-',
|
|
103
|
+
selector: ':root',
|
|
104
|
+
includeReset: true
|
|
105
|
+
});
|
|
273
106
|
|
|
274
|
-
|
|
275
|
-
mase compile Button.contract.dsl -o Button.ts
|
|
107
|
+
console.log(css);
|
|
276
108
|
```
|
|
277
109
|
|
|
278
|
-
|
|
110
|
+
### Option 3: Tailwind Preset
|
|
279
111
|
|
|
280
|
-
|
|
112
|
+
**tailwind.config.js**
|
|
113
|
+
```javascript
|
|
114
|
+
import { createMasePreset } from '@damarkuncoro/meta-architecture-style-engine/tailwind';
|
|
281
115
|
|
|
282
|
-
|
|
283
|
-
|
|
116
|
+
export default {
|
|
117
|
+
presets: [
|
|
118
|
+
createMasePreset({
|
|
119
|
+
useCssVariables: true,
|
|
120
|
+
variablePrefix: '--'
|
|
121
|
+
})
|
|
122
|
+
]
|
|
123
|
+
}
|
|
284
124
|
```
|
|
285
125
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
### Step 5: Use in Your Application
|
|
126
|
+
### Option 4: React Integration
|
|
289
127
|
|
|
290
|
-
```
|
|
291
|
-
import { StyleProvider,
|
|
292
|
-
import { ButtonContract } from './Button';
|
|
128
|
+
```typescript
|
|
129
|
+
import { StyleProvider, useStyleContract } from '@damarkuncoro/meta-architecture-style-engine';
|
|
293
130
|
|
|
294
131
|
function App() {
|
|
295
132
|
return (
|
|
296
|
-
<StyleProvider
|
|
297
|
-
<
|
|
133
|
+
<StyleProvider>
|
|
134
|
+
<YourComponent />
|
|
298
135
|
</StyleProvider>
|
|
299
136
|
);
|
|
300
137
|
}
|
|
301
138
|
|
|
302
|
-
function
|
|
303
|
-
const {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
platform: 'web'
|
|
139
|
+
function YourComponent() {
|
|
140
|
+
const { resolveStyles } = useStyleContract();
|
|
141
|
+
const styles = resolveStyles({
|
|
142
|
+
backgroundColor: 'primary',
|
|
143
|
+
padding: 'md',
|
|
144
|
+
borderRadius: 'md'
|
|
309
145
|
});
|
|
310
146
|
|
|
311
|
-
return
|
|
312
|
-
<button className={buttonStyles.className}>
|
|
313
|
-
Click me
|
|
314
|
-
</button>
|
|
315
|
-
);
|
|
147
|
+
return <div style={styles}>Hello MASE!</div>;
|
|
316
148
|
}
|
|
317
149
|
```
|
|
318
150
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
## π Usage
|
|
322
|
-
|
|
323
|
-
### Runtime Usage
|
|
324
|
-
|
|
325
|
-
#### StyleProvider
|
|
326
|
-
|
|
327
|
-
Wrap your application with the `StyleProvider` to enable style resolution.
|
|
328
|
-
|
|
329
|
-
**Web Usage (Default):**
|
|
151
|
+
## π Documentation
|
|
330
152
|
|
|
331
|
-
|
|
332
|
-
|
|
153
|
+
### Core Documentation
|
|
154
|
+
- [Quick Start Guide](docs/quick-start.md) - Get started with MASE in minutes
|
|
155
|
+
- [Architecture Diagram](docs/architecture-diagram.md) - System architecture overview
|
|
156
|
+
- [DSL Reference](docs/dsl-reference.md) - Domain-specific language guide
|
|
157
|
+
- [Migration Guide](docs/migration-guide.md) - Migrate from other systems
|
|
158
|
+
- [Troubleshooting](docs/troubleshooting.md) - Common issues and solutions
|
|
333
159
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
}
|
|
341
|
-
```
|
|
342
|
-
|
|
343
|
-
**Native Usage (with Adapter):**
|
|
160
|
+
### Integration Guides
|
|
161
|
+
- [CSS Import Guide](docs/integrations/css-import-guide.md) - Using MASE with CSS imports
|
|
162
|
+
- [Atomic CSS Complete Guide](docs/integrations/atomic-css-complete-guide.md) - Complete utility reference
|
|
163
|
+
- [Next.js Integration](docs/integrations/nextjs.md) - Next.js specific setup
|
|
164
|
+
- [React Native Integration](docs/integrations/react-native.md) - React Native setup
|
|
165
|
+
- [Storybook Integration](docs/integrations/storybook.md) - Storybook integration
|
|
344
166
|
|
|
345
|
-
|
|
167
|
+
### Development Documentation
|
|
168
|
+
- [Development Guide](docs/development/guide.md) - Contributing to MASE
|
|
169
|
+
- [Integration Layer Review](docs/development/integration-layer-comprehensive-review.md) - Integration layer analysis
|
|
170
|
+
- [Recommendations Implementation](docs/development/recommendations-implementation.md) - Implemented improvements
|
|
171
|
+
- [Atomic CSS Implementation](docs/development/final-atomic-css-implementation.md) - Complete implementation report
|
|
172
|
+
- [Comprehensive Atomic CSS Implementation](docs/development/comprehensive-atomic-css-implementation.md) - Detailed implementation guide
|
|
346
173
|
|
|
347
|
-
|
|
348
|
-
|
|
174
|
+
### Examples
|
|
175
|
+
- [Basic Examples](examples/basic/) - Simple component examples
|
|
176
|
+
- [Advanced Examples](examples/advanced/) - Complex use cases
|
|
177
|
+
- [Integration Examples](examples/integration/) - Integration patterns
|
|
349
178
|
|
|
350
|
-
|
|
179
|
+
## π¨ Utility Classes Reference
|
|
351
180
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
</StyleProvider>
|
|
360
|
-
);
|
|
361
|
-
}
|
|
181
|
+
### Layout
|
|
182
|
+
```css
|
|
183
|
+
.block { display: block; }
|
|
184
|
+
.flex { display: flex; }
|
|
185
|
+
.grid { display: grid; }
|
|
186
|
+
.relative { position: relative; }
|
|
187
|
+
.z-10 { z-index: 10; }
|
|
362
188
|
```
|
|
363
189
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
function MyComponent() {
|
|
372
|
-
const { theme, device, platform } = useStyleContext();
|
|
373
|
-
|
|
374
|
-
return (
|
|
375
|
-
<div>
|
|
376
|
-
Current theme: {theme}
|
|
377
|
-
Current device: {device}
|
|
378
|
-
</div>
|
|
379
|
-
);
|
|
380
|
-
}
|
|
190
|
+
### Flexbox
|
|
191
|
+
```css
|
|
192
|
+
.flex-row { flex-direction: row; }
|
|
193
|
+
.items-center { align-items: center; }
|
|
194
|
+
.justify-between { justify-content: space-between; }
|
|
195
|
+
.gap-4 { gap: 1rem; }
|
|
381
196
|
```
|
|
382
197
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
```typescript
|
|
388
|
-
import { StyleContract } from '@damarkuncoro/meta-architecture-style-engine';
|
|
389
|
-
|
|
390
|
-
const buttonContract = new StyleContract({
|
|
391
|
-
intent: 'color.primary',
|
|
392
|
-
padding: 'space.md',
|
|
393
|
-
borderRadius: 'radius.md'
|
|
394
|
-
});
|
|
395
|
-
|
|
396
|
-
const resolved = buttonContract.resolve({
|
|
397
|
-
theme: 'light',
|
|
398
|
-
device: 'desktop',
|
|
399
|
-
platform: 'web'
|
|
400
|
-
});
|
|
198
|
+
### Grid
|
|
199
|
+
```css
|
|
200
|
+
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
201
|
+
.col-span-2 { grid-column: span 2 / span 2; }
|
|
401
202
|
```
|
|
402
203
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
import {
|
|
409
|
-
StyleResolutionEngine,
|
|
410
|
-
TokenRegistry,
|
|
411
|
-
ThemeResolver
|
|
412
|
-
} from '@damarkuncoro/meta-architecture-style-engine';
|
|
413
|
-
|
|
414
|
-
// Create engine
|
|
415
|
-
const tokenRegistry = new TokenRegistry();
|
|
416
|
-
const themeResolver = new ThemeResolver();
|
|
417
|
-
const engine = new StyleResolutionEngine(tokenRegistry, themeResolver);
|
|
418
|
-
|
|
419
|
-
// Define contract
|
|
420
|
-
const contract = {
|
|
421
|
-
intent: 'color.primary',
|
|
422
|
-
padding: 'space.md'
|
|
423
|
-
};
|
|
424
|
-
|
|
425
|
-
// Define constitution
|
|
426
|
-
const constitution = {
|
|
427
|
-
componentName: 'Button',
|
|
428
|
-
rules: [
|
|
429
|
-
{
|
|
430
|
-
property: 'intent',
|
|
431
|
-
domain: 'interaction',
|
|
432
|
-
allowedTokens: ['color.primary', 'color.secondary']
|
|
433
|
-
},
|
|
434
|
-
{
|
|
435
|
-
property: 'padding',
|
|
436
|
-
domain: 'layout',
|
|
437
|
-
allowedTokens: ['space.sm', 'space.md', 'space.lg']
|
|
438
|
-
}
|
|
439
|
-
]
|
|
440
|
-
};
|
|
441
|
-
|
|
442
|
-
// Resolve
|
|
443
|
-
const result = engine.resolve(contract, constitution);
|
|
444
|
-
|
|
445
|
-
console.log(result.className); // "bg-primary p-md"
|
|
446
|
-
console.log(result.valid); // true
|
|
204
|
+
### Spacing
|
|
205
|
+
```css
|
|
206
|
+
.p-4 { padding: 1rem; }
|
|
207
|
+
.m-4 { margin: 1rem; }
|
|
208
|
+
.gap-4 { gap: 1rem; }
|
|
447
209
|
```
|
|
448
210
|
|
|
449
|
-
###
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
mase init my-app
|
|
211
|
+
### Typography
|
|
212
|
+
```css
|
|
213
|
+
.text-lg { font-size: 1.125rem; }
|
|
214
|
+
.font-bold { font-weight: 700; }
|
|
215
|
+
.leading-relaxed { line-height: 1.625; }
|
|
455
216
|
```
|
|
456
217
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
218
|
+
### Color
|
|
219
|
+
```css
|
|
220
|
+
.bg-primary { background-color: var(--color-primary); }
|
|
221
|
+
.text-white { color: var(--color-white); }
|
|
222
|
+
.border-gray-200 { border-color: var(--color-gray-200); }
|
|
461
223
|
```
|
|
462
224
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
-
|
|
466
|
-
-
|
|
467
|
-
|
|
468
|
-
#### Validate Contract
|
|
469
|
-
|
|
470
|
-
```bash
|
|
471
|
-
mase validate Button.contract.dsl
|
|
225
|
+
### Effects
|
|
226
|
+
```css
|
|
227
|
+
.rounded-md { border-radius: 0.375rem; }
|
|
228
|
+
.shadow-lg { box-shadow: var(--shadow-lg); }
|
|
229
|
+
.opacity-50 { opacity: 0.5; }
|
|
472
230
|
```
|
|
473
231
|
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
-
|
|
477
|
-
-
|
|
478
|
-
|
|
479
|
-
#### Generate CSS
|
|
480
|
-
|
|
481
|
-
```bash
|
|
482
|
-
mase generate-css Button.contract.dsl -o button.css
|
|
232
|
+
### Filters
|
|
233
|
+
```css
|
|
234
|
+
.blur-md { filter: blur(8px); }
|
|
235
|
+
.brightness-125 { filter: brightness(1.25); }
|
|
236
|
+
.backdrop-blur-md { backdrop-filter: blur(8px); }
|
|
483
237
|
```
|
|
484
238
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
-
|
|
488
|
-
-
|
|
489
|
-
-
|
|
490
|
-
|
|
491
|
-
#### Watch for Changes
|
|
492
|
-
|
|
493
|
-
```bash
|
|
494
|
-
mase watch Button.contract.dsl
|
|
239
|
+
### Interactivity
|
|
240
|
+
```css
|
|
241
|
+
.cursor-pointer { cursor: pointer; }
|
|
242
|
+
.pointer-events-none { pointer-events: none; }
|
|
243
|
+
.select-none { user-select: none; }
|
|
495
244
|
```
|
|
496
245
|
|
|
497
|
-
|
|
498
|
-
- `--command <command>` - Command to run on change
|
|
499
|
-
- `--debounce <ms>` - Debounce time in ms
|
|
246
|
+
## π Dark Mode
|
|
500
247
|
|
|
501
|
-
|
|
248
|
+
MASE provides automatic dark mode support:
|
|
502
249
|
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
contract Button {
|
|
509
|
-
domain: interaction
|
|
510
|
-
|
|
511
|
-
intent {
|
|
512
|
-
allows: [color.primary, color.secondary]
|
|
513
|
-
default: color.primary
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
padding {
|
|
517
|
-
allows: [space.sm, space.md, space.lg]
|
|
518
|
-
default: space.md
|
|
519
|
-
}
|
|
250
|
+
```css
|
|
251
|
+
/* Light mode */
|
|
252
|
+
.button {
|
|
253
|
+
background-color: var(--color-primary);
|
|
254
|
+
color: var(--color-white);
|
|
520
255
|
}
|
|
521
|
-
```
|
|
522
|
-
|
|
523
|
-
#### Responsive Styling
|
|
524
256
|
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
padding {
|
|
530
|
-
allows: [space.sm, space.md, space.lg]
|
|
531
|
-
default: space.md
|
|
532
|
-
|
|
533
|
-
constraints {
|
|
534
|
-
mobile: [space.sm, space.md]
|
|
535
|
-
desktop: [space.md, space.lg]
|
|
536
|
-
}
|
|
537
|
-
}
|
|
257
|
+
/* Dark mode */
|
|
258
|
+
[data-theme="dark"] .button {
|
|
259
|
+
background-color: var(--color-primary-dark);
|
|
260
|
+
color: var(--color-white-dark);
|
|
538
261
|
}
|
|
539
262
|
```
|
|
540
263
|
|
|
541
|
-
|
|
264
|
+
### Theme Switching
|
|
542
265
|
|
|
543
|
-
```
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
intent {
|
|
548
|
-
allows: [color.primary, color.secondary]
|
|
549
|
-
default: color.primary
|
|
550
|
-
|
|
551
|
-
constraints {
|
|
552
|
-
hover: [color.primary.hover, color.secondary.hover]
|
|
553
|
-
active: [color.primary.active, color.secondary.active]
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
```
|
|
558
|
-
|
|
559
|
-
#### Theme Support
|
|
560
|
-
|
|
561
|
-
```dsl
|
|
562
|
-
contract Card {
|
|
563
|
-
domain: layout
|
|
564
|
-
|
|
565
|
-
background {
|
|
566
|
-
allows: [surface.card, surface.ground]
|
|
567
|
-
default: surface.card
|
|
568
|
-
|
|
569
|
-
constraints {
|
|
570
|
-
dark: [surface.card.dark, surface.ground.dark]
|
|
571
|
-
}
|
|
572
|
-
}
|
|
266
|
+
```javascript
|
|
267
|
+
function setTheme(theme) {
|
|
268
|
+
document.documentElement.setAttribute('data-theme', theme);
|
|
269
|
+
localStorage.setItem('theme', theme);
|
|
573
270
|
}
|
|
574
|
-
```
|
|
575
|
-
|
|
576
|
-
---
|
|
577
|
-
|
|
578
|
-
## π§ API Reference
|
|
579
|
-
|
|
580
|
-
### Core Exports
|
|
581
|
-
|
|
582
|
-
#### Domain Layer
|
|
583
|
-
|
|
584
|
-
```typescript
|
|
585
|
-
// Types
|
|
586
|
-
export * from './domain/types';
|
|
587
|
-
|
|
588
|
-
// Core Engine
|
|
589
|
-
export { StyleResolutionEngine } from './domain/StyleResolutionEngine';
|
|
590
|
-
export { CanonicalStyleGraph } from './domain/CanonicalStyleGraph';
|
|
591
|
-
export { ContextBinder } from './domain/ContextBinder';
|
|
592
|
-
export { ViolationEngine } from './domain/ViolationEngine';
|
|
593
|
-
|
|
594
|
-
// Registries
|
|
595
|
-
export { TokenRegistry } from './domain/TokenRegistry';
|
|
596
|
-
export { ThemeResolver } from './domain/ThemeResolver';
|
|
597
|
-
export { ContextFactory } from './domain/ContextFactory';
|
|
598
|
-
```
|
|
599
|
-
|
|
600
|
-
#### Runtime Layer
|
|
601
|
-
|
|
602
|
-
```typescript
|
|
603
|
-
export { StyleContract } from './runtime/StyleContract';
|
|
604
|
-
export { StyleProvider } from './runtime/StyleProvider';
|
|
605
|
-
```
|
|
606
|
-
|
|
607
|
-
#### Adapter Layer
|
|
608
|
-
|
|
609
|
-
```typescript
|
|
610
|
-
export { MasePlugin } from './adapter/MasePlugin';
|
|
611
|
-
export { createPipeline } from './adapter/pipeline-factory';
|
|
612
|
-
export * from './adapter/rules';
|
|
613
|
-
```
|
|
614
|
-
|
|
615
|
-
#### Data Layer
|
|
616
|
-
|
|
617
|
-
```typescript
|
|
618
|
-
export * from './data/tokens';
|
|
619
|
-
export * from './data/constitutions';
|
|
620
|
-
```
|
|
621
|
-
|
|
622
|
-
#### DSL Layer
|
|
623
|
-
|
|
624
|
-
```typescript
|
|
625
|
-
export {
|
|
626
|
-
ContractDSLTokenizer,
|
|
627
|
-
ContractDSLParser,
|
|
628
|
-
ContractDSLValidator,
|
|
629
|
-
ContractDSLCompiler
|
|
630
|
-
} from './dsl';
|
|
631
|
-
```
|
|
632
271
|
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
Materializer,
|
|
638
|
-
MaterializationContext,
|
|
639
|
-
MaterializationResult
|
|
640
|
-
} from './materializer';
|
|
641
|
-
|
|
642
|
-
export {
|
|
643
|
-
MaterializationError,
|
|
644
|
-
CSSMaterializer,
|
|
645
|
-
RNMaterializer,
|
|
646
|
-
PDFMaterializer
|
|
647
|
-
} from './materializer';
|
|
272
|
+
// Initialize theme
|
|
273
|
+
const savedTheme = localStorage.getItem('theme');
|
|
274
|
+
const systemTheme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
275
|
+
setTheme(savedTheme || systemTheme);
|
|
648
276
|
```
|
|
649
277
|
|
|
650
|
-
|
|
278
|
+
## π§ CLI Commands
|
|
651
279
|
|
|
652
|
-
|
|
280
|
+
```bash
|
|
281
|
+
# Initialize MASE in your project
|
|
282
|
+
npx @damarkuncoro/meta-architecture-style-engine init
|
|
653
283
|
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
resolve(context: ResolutionContext): StyleResolutionResult;
|
|
657
|
-
validate(): ValidationResult;
|
|
658
|
-
}
|
|
659
|
-
```
|
|
284
|
+
# Compile style contracts
|
|
285
|
+
npx @damarkuncoro/meta-architecture-style-engine compile <contract-file>
|
|
660
286
|
|
|
661
|
-
|
|
287
|
+
# Generate CSS
|
|
288
|
+
npx @damarkuncoro/meta-architecture-style-engine generate-css
|
|
662
289
|
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
valid: boolean;
|
|
666
|
-
className?: string;
|
|
667
|
-
styles?: Record<string, any>;
|
|
668
|
-
violations?: Violation[];
|
|
669
|
-
}
|
|
670
|
-
```
|
|
290
|
+
# Validate contracts
|
|
291
|
+
npx @damarkuncoro/meta-architecture-style-engine validate <contract-file>
|
|
671
292
|
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
```typescript
|
|
675
|
-
interface ResolutionContext {
|
|
676
|
-
theme: 'light' | 'dark';
|
|
677
|
-
device: 'mobile' | 'tablet' | 'desktop';
|
|
678
|
-
platform: 'web' | 'native' | 'pdf';
|
|
679
|
-
state?: Record<string, any>;
|
|
680
|
-
}
|
|
293
|
+
# Watch for changes
|
|
294
|
+
npx @damarkuncoro/meta-architecture-style-engine watch <contract-file>
|
|
681
295
|
```
|
|
682
296
|
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
## π Examples
|
|
686
|
-
|
|
687
|
-
### Phase 2 Examples
|
|
688
|
-
|
|
689
|
-
Explore advanced Phase 2 features:
|
|
690
|
-
|
|
691
|
-
- **[Interactive DSL Playground](./examples/advanced/dsl-playground/README.md)** - Live DSL editor with real-time validation
|
|
692
|
-
- **[Advanced ContractEntity](./examples/advanced/contract-entity/README.md)** - Lifecycle hooks, middleware, composition
|
|
297
|
+
## π Performance
|
|
693
298
|
|
|
694
|
-
|
|
299
|
+
MASE is optimized for performance:
|
|
695
300
|
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
301
|
+
- **Caching** - 50-90% improvement for repeated style resolutions
|
|
302
|
+
- **Efficient Generation** - Minimal CSS output with no duplicates
|
|
303
|
+
- **Type Safety** - Compile-time type checking reduces runtime errors
|
|
304
|
+
- **Lazy Evaluation** - Only generate what's needed
|
|
699
305
|
|
|
700
|
-
|
|
701
|
-
const buttonContract = new StyleContract({
|
|
702
|
-
intent: 'color.primary',
|
|
703
|
-
padding: 'space.md',
|
|
704
|
-
borderRadius: 'radius.md',
|
|
705
|
-
fontSize: 'text.base',
|
|
706
|
-
fontWeight: 'font.semibold'
|
|
707
|
-
});
|
|
306
|
+
### Benchmarks
|
|
708
307
|
|
|
709
|
-
|
|
710
|
-
const { theme, device } = useStyleContext();
|
|
711
|
-
|
|
712
|
-
const styles = buttonContract.resolve({
|
|
713
|
-
theme,
|
|
714
|
-
device,
|
|
715
|
-
platform: 'web',
|
|
716
|
-
state: { variant }
|
|
717
|
-
});
|
|
718
|
-
|
|
719
|
-
return (
|
|
720
|
-
<button className={styles.className}>
|
|
721
|
-
{children}
|
|
722
|
-
</button>
|
|
723
|
-
);
|
|
724
|
-
}
|
|
308
|
+
Run performance benchmarks:
|
|
725
309
|
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
<StyleProvider initialTheme="light">
|
|
729
|
-
<Button>Click me</Button>
|
|
730
|
-
</StyleProvider>
|
|
731
|
-
);
|
|
732
|
-
}
|
|
733
|
-
```
|
|
734
|
-
|
|
735
|
-
### Card Component with Responsive Design
|
|
736
|
-
|
|
737
|
-
```tsx
|
|
738
|
-
import React from 'react';
|
|
739
|
-
import { StyleProvider, useStyleContext, StyleContract } from '@damarkuncoro/meta-architecture-style-engine';
|
|
740
|
-
|
|
741
|
-
const cardContract = new StyleContract({
|
|
742
|
-
background: 'surface.card',
|
|
743
|
-
padding: 'space.lg',
|
|
744
|
-
borderRadius: 'radius.lg',
|
|
745
|
-
shadow: 'shadow.md'
|
|
746
|
-
});
|
|
747
|
-
|
|
748
|
-
function Card({ children }: CardProps) {
|
|
749
|
-
const { theme, device } = useStyleContext();
|
|
750
|
-
|
|
751
|
-
const styles = cardContract.resolve({
|
|
752
|
-
theme,
|
|
753
|
-
device,
|
|
754
|
-
platform: 'web'
|
|
755
|
-
});
|
|
756
|
-
|
|
757
|
-
return (
|
|
758
|
-
<div className={styles.className}>
|
|
759
|
-
{children}
|
|
760
|
-
</div>
|
|
761
|
-
);
|
|
762
|
-
}
|
|
310
|
+
```bash
|
|
311
|
+
npm run benchmark
|
|
763
312
|
```
|
|
764
313
|
|
|
765
|
-
|
|
314
|
+
Expected results:
|
|
315
|
+
- Style Resolution (No Cache): ~0.5-2ms per operation
|
|
316
|
+
- Style Resolution (With Cache): ~0.01-0.1ms per operation (90-95% faster)
|
|
317
|
+
- Cache Hit Rate: 100% for repeated operations
|
|
766
318
|
|
|
767
|
-
|
|
768
|
-
import {
|
|
769
|
-
StyleResolutionEngine,
|
|
770
|
-
TokenRegistry,
|
|
771
|
-
ThemeResolver,
|
|
772
|
-
CSSMaterializer
|
|
773
|
-
} from '@damarkuncoro/meta-architecture-style-engine';
|
|
774
|
-
|
|
775
|
-
// Setup
|
|
776
|
-
const tokenRegistry = new TokenRegistry();
|
|
777
|
-
const themeResolver = new ThemeResolver();
|
|
778
|
-
const engine = new StyleResolutionEngine(tokenRegistry, themeResolver);
|
|
779
|
-
const cssMaterializer = new CSSMaterializer();
|
|
780
|
-
|
|
781
|
-
// Define contract
|
|
782
|
-
const contract = {
|
|
783
|
-
background: 'surface.card',
|
|
784
|
-
padding: 'space.lg',
|
|
785
|
-
borderRadius: 'radius.lg'
|
|
786
|
-
};
|
|
787
|
-
|
|
788
|
-
// Define constitution
|
|
789
|
-
const constitution = {
|
|
790
|
-
componentName: 'Card',
|
|
791
|
-
domain: 'layout',
|
|
792
|
-
rules: [
|
|
793
|
-
{
|
|
794
|
-
property: 'background',
|
|
795
|
-
allowedTokens: ['surface.card', 'surface.ground']
|
|
796
|
-
},
|
|
797
|
-
{
|
|
798
|
-
property: 'padding',
|
|
799
|
-
allowedTokens: ['space.sm', 'space.md', 'space.lg']
|
|
800
|
-
},
|
|
801
|
-
{
|
|
802
|
-
property: 'borderRadius',
|
|
803
|
-
allowedTokens: ['radius.sm', 'radius.md', 'radius.lg']
|
|
804
|
-
}
|
|
805
|
-
]
|
|
806
|
-
};
|
|
807
|
-
|
|
808
|
-
// Resolve
|
|
809
|
-
const context = {
|
|
810
|
-
theme: 'light',
|
|
811
|
-
device: 'desktop',
|
|
812
|
-
platform: 'web'
|
|
813
|
-
};
|
|
814
|
-
|
|
815
|
-
const result = engine.resolve(contract, constitution, context);
|
|
319
|
+
## ποΈ Architecture
|
|
816
320
|
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
321
|
+
MASE follows a layered architecture:
|
|
322
|
+
|
|
323
|
+
```
|
|
324
|
+
βββββββββββββββββββββββββββββββββββββββββββ
|
|
325
|
+
β Integration Layer β
|
|
326
|
+
β ββββββββββββ¬βββββββββββ¬βββββββββββ
|
|
327
|
+
β β PostCSS β Atomic β Tailwind ββ
|
|
328
|
+
β β Plugin β CSS β Preset ββ
|
|
329
|
+
β ββββββββββββ΄βββββββββββ΄βββββββββββ
|
|
330
|
+
βββββββββββββββββββββββββββββββββββββββββββ
|
|
331
|
+
β
|
|
332
|
+
βββββββββββββββββββββββββββββββββββββββββββ
|
|
333
|
+
β Domain Layer β
|
|
334
|
+
β ββββββββββββ¬βββββββββββ¬βββββββββββ
|
|
335
|
+
β β Tokens βGovernanceβResolutionββ
|
|
336
|
+
β β Registry β Engine β Engine ββ
|
|
337
|
+
β ββββββββββββ΄βββββββββββ΄βββββββββββ
|
|
338
|
+
βββββββββββββββββββββββββββββββββββββββββββ
|
|
339
|
+
β
|
|
340
|
+
βββββββββββββββββββββββββββββββββββββββββββ
|
|
341
|
+
β Materialization Layer β
|
|
342
|
+
β ββββββββββββ¬βββββββββββ¬βββββββββββ
|
|
343
|
+
β β CSS β RN β PDF ββ
|
|
344
|
+
β βMaterializerβMaterializerβMaterializerββ
|
|
345
|
+
β ββββββββββββ΄βββββββββββ΄βββββββββββ
|
|
346
|
+
βββββββββββββββββββββββββββββββββββββββββββ
|
|
347
|
+
β
|
|
348
|
+
βββββββββββββββββββββββββββββββββββββββββββ
|
|
349
|
+
β Runtime Layer β
|
|
350
|
+
β ββββββββββββ¬βββββββββββ¬βββββββββββ
|
|
351
|
+
β β Web β RN βAdapter ββ
|
|
352
|
+
β β Adapter β Adapter βFactory ββ
|
|
353
|
+
β ββββββββββββ΄βββββββββββ΄βββββββββββ
|
|
354
|
+
βββββββββββββββββββββββββββββββββββββββββββ
|
|
822
355
|
```
|
|
823
356
|
|
|
824
|
-
|
|
357
|
+
## π€ Contributing
|
|
825
358
|
|
|
826
|
-
|
|
359
|
+
We welcome contributions! Please see our [Development Guide](docs/development/guide.md) for details.
|
|
827
360
|
|
|
828
|
-
### Setup
|
|
361
|
+
### Development Setup
|
|
829
362
|
|
|
830
363
|
```bash
|
|
831
364
|
# Clone the repository
|
|
@@ -835,182 +368,43 @@ cd meta-architecture-style-engine
|
|
|
835
368
|
# Install dependencies
|
|
836
369
|
npm install
|
|
837
370
|
|
|
838
|
-
# Build the project
|
|
839
|
-
npm run build
|
|
840
|
-
|
|
841
371
|
# Run tests
|
|
842
372
|
npm test
|
|
843
|
-
```
|
|
844
373
|
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
```
|
|
848
|
-
meta-architecture-style-engine/
|
|
849
|
-
βββ src/
|
|
850
|
-
β βββ adapter/ # Plugin system and pipeline factory
|
|
851
|
-
β βββ cli/ # Command-line interface
|
|
852
|
-
β βββ data/ # Tokens and constitutions
|
|
853
|
-
β βββ domain/ # Core engine (SRE)
|
|
854
|
-
β βββ dsl/ # Contract DSL compiler
|
|
855
|
-
β βββ materializer/ # Platform materializers (SME)
|
|
856
|
-
β βββ runtime/ # React runtime components
|
|
857
|
-
βββ docs/ # Documentation
|
|
858
|
-
βββ __tests__/ # Test files
|
|
859
|
-
βββ package.json
|
|
860
|
-
βββ tsconfig.json
|
|
861
|
-
βββ tsup.config.ts # Build configuration
|
|
862
|
-
```
|
|
863
|
-
|
|
864
|
-
### Scripts
|
|
865
|
-
|
|
866
|
-
```bash
|
|
867
|
-
# Build
|
|
374
|
+
# Build the project
|
|
868
375
|
npm run build
|
|
869
376
|
|
|
870
|
-
# Test
|
|
871
|
-
npm test
|
|
872
|
-
|
|
873
|
-
# Clean build artifacts
|
|
874
|
-
npm run clean
|
|
875
|
-
|
|
876
377
|
# Run CLI
|
|
877
378
|
npm run cli
|
|
878
379
|
```
|
|
879
380
|
|
|
880
|
-
### Testing
|
|
881
|
-
|
|
882
|
-
MASE uses Vitest for testing. Tests are organized by component and follow the test matrix specification:
|
|
883
|
-
|
|
884
|
-
- **Valid Contract**: Happy path scenarios
|
|
885
|
-
- **Invalid Token**: Token not in registry
|
|
886
|
-
- **Invalid Semantic**: Wrong semantic key
|
|
887
|
-
- **Domain Violation**: Cross-domain properties
|
|
888
|
-
- **Context Fallback**: Graceful degradation
|
|
889
|
-
- **Hard Rejection**: Fatal violations
|
|
890
|
-
- **Performance**: < 5ms resolution per component
|
|
891
|
-
|
|
892
|
-
### Quality Metrics
|
|
893
|
-
|
|
894
|
-
| Metric | Target | Description |
|
|
895
|
-
| :--- | :--- | :--- |
|
|
896
|
-
| **Type Safety** | 100% | No `any`, fully typed contracts |
|
|
897
|
-
| **Platform Agnostic** | 100% | SRE code has no CSS/Web terminology |
|
|
898
|
-
| **Immutability** | Enforced | CSG and Token Registry are `readonly` |
|
|
899
|
-
| **Audit Trail** | 100% | Every resolution decision is traceable |
|
|
900
|
-
|
|
901
|
-
---
|
|
902
|
-
|
|
903
|
-
## π€ Contributing
|
|
904
|
-
|
|
905
|
-
We welcome contributions! Please follow these guidelines:
|
|
906
|
-
|
|
907
|
-
### Contribution Guidelines
|
|
908
|
-
|
|
909
|
-
1. **Strict Separation**: Don't mix CSS logic in the SRE
|
|
910
|
-
2. **Spec-First**: Discuss constitution changes before coding
|
|
911
|
-
3. **Violation as Feature**: Errors are governance features, not bugs
|
|
912
|
-
4. **Type Safety**: Maintain 100% type safety
|
|
913
|
-
5. **Testing**: Ensure all tests pass before submitting PR
|
|
914
|
-
|
|
915
|
-
### Development Workflow
|
|
916
|
-
|
|
917
|
-
1. Fork the repository
|
|
918
|
-
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
919
|
-
3. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
920
|
-
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
921
|
-
5. Open a Pull Request
|
|
922
|
-
|
|
923
|
-
### Code of Conduct
|
|
924
|
-
|
|
925
|
-
- Be respectful and inclusive
|
|
926
|
-
- Provide constructive feedback
|
|
927
|
-
- Focus on what is best for the community
|
|
928
|
-
- Show empathy towards other community members
|
|
929
|
-
|
|
930
|
-
---
|
|
931
|
-
|
|
932
381
|
## π License
|
|
933
382
|
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
---
|
|
383
|
+
MIT License - see [LICENSE](LICENSE) file for details
|
|
937
384
|
|
|
938
385
|
## π Acknowledgments
|
|
939
386
|
|
|
940
|
-
- Inspired by
|
|
387
|
+
- Inspired by Tailwind CSS's utility-first approach
|
|
941
388
|
- Built with TypeScript for type safety
|
|
942
|
-
-
|
|
389
|
+
- Designed for modern web development
|
|
390
|
+
- Part of the Meta Architecture ecosystem
|
|
943
391
|
|
|
944
|
-
|
|
392
|
+
## π Support
|
|
945
393
|
|
|
946
|
-
|
|
394
|
+
- π [Documentation](docs/)
|
|
395
|
+
- π [Issue Tracker](https://github.com/damarkuncoro/meta-architecture-style-engine/issues)
|
|
396
|
+
- π¬ [Discussions](https://github.com/damarkuncoro/meta-architecture-style-engine/discussions)
|
|
397
|
+
- π§ [Email](mailto:support@damarkuncoro.com)
|
|
947
398
|
|
|
948
|
-
|
|
399
|
+
## π Related Projects
|
|
949
400
|
|
|
950
|
-
-
|
|
951
|
-
- **[Quick Start Guide](./docs/quick-start.md)** - Get started in 5 minutes
|
|
952
|
-
- **[Development Guide](./docs/development.md)** - Comprehensive development guide
|
|
953
|
-
- **[Phase 2: Integration Design & DSL](./docs/phase2-integration-design.md)** - Context-awareness, ContractEntity, and DSL features
|
|
954
|
-
- **[Architecture Diagrams](./docs/architecture-diagram.md)** - Visual architecture documentation
|
|
955
|
-
- **[Performance Benchmarks](./docs/benchmarks.md)** - Performance metrics and comparisons
|
|
956
|
-
- **[Migration Guide](./docs/migration-guide.md)** - Migrate from Tailwind/CSS-in-JS
|
|
957
|
-
- **[DSL Reference](./docs/dsl-reference.md)** - Quick reference card for DSL syntax
|
|
958
|
-
- **[Interactive Demo](./docs/interactive-demo.md)** - Interactive examples and live demos
|
|
959
|
-
- **[Troubleshooting](./docs/troubleshooting.md)** - Common issues and solutions
|
|
960
|
-
|
|
961
|
-
### Framework Integrations
|
|
962
|
-
|
|
963
|
-
- **[Next.js Integration](./docs/integrations/nextjs.md)** - Integrate MASE with Next.js
|
|
964
|
-
- **[React Native Integration](./docs/integrations/react-native.md)** - Integrate MASE with React Native
|
|
965
|
-
- **[Storybook Integration](./docs/integrations/storybook.md)** - Integrate MASE with Storybook
|
|
966
|
-
|
|
967
|
-
### Examples
|
|
968
|
-
|
|
969
|
-
- **[Examples Directory](./examples/README.md)** - Comprehensive examples collection
|
|
970
|
-
- **[Basic Examples](./examples/basic/)** - Button, Card, Input components
|
|
971
|
-
- **[Advanced Examples](./examples/advanced/)** - Responsive, theming, animations
|
|
972
|
-
- **[Real-World Apps](./examples/real-world/)** - E-commerce, Dashboard, Social apps
|
|
973
|
-
|
|
974
|
-
### Community
|
|
975
|
-
|
|
976
|
-
- **[GitHub Issues](https://github.com/damarkuncoro/meta-architecture-style-engine/issues)** - Report bugs
|
|
977
|
-
- **[GitHub Discussions](https://github.com/damarkuncoro/meta-architecture-style-engine/discussions)** - Ask questions
|
|
978
|
-
- **[Pull Requests](https://github.com/damarkuncoro/meta-architecture-style-engine/pulls)** - Contribute code
|
|
979
|
-
|
|
980
|
-
---
|
|
981
|
-
|
|
982
|
-
## πΊοΈ Roadmap
|
|
983
|
-
|
|
984
|
-
### β
Phase 0: Prototype (v0.1)
|
|
985
|
-
- Basic `TokenRegistry` & `StyleRule`
|
|
986
|
-
- Simple `StyleValidator` (Runtime)
|
|
987
|
-
- `StrictButton` component demo
|
|
988
|
-
|
|
989
|
-
### β
Phase 1: Review & Ratify (Materialization)
|
|
990
|
-
- Card Governance implementation
|
|
991
|
-
- Testing strategy with Vitest
|
|
992
|
-
- Domain expansion (Shadow, Surface)
|
|
993
|
-
|
|
994
|
-
### π Phase 2: Integration Design & DSL
|
|
995
|
-
- Context-Awareness for responsive design
|
|
996
|
-
- ContractEntity abstract class
|
|
997
|
-
- DSL Design for declarative contracts
|
|
998
|
-
|
|
999
|
-
### π Phase 3: SRE Implementation
|
|
1000
|
-
- Style resolution algorithms
|
|
1001
|
-
- Context Binder for variants/conditions
|
|
1002
|
-
|
|
1003
|
-
### π Phase 4: SME (Materializers)
|
|
1004
|
-
- Semantic node to CSS Properties mapping
|
|
1005
|
-
- Atomic CSS generation optimization
|
|
401
|
+
- [@damarkuncoro/meta-architecture](https://github.com/damarkuncoro/meta-architecture) - The core Meta Architecture framework
|
|
1006
402
|
|
|
1007
403
|
---
|
|
1008
404
|
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
**Built with β€οΈ by Damar Kuncoro**
|
|
405
|
+
**MASE** - Meta Architecture Style Engine
|
|
1012
406
|
|
|
1013
|
-
|
|
1014
|
-
[](https://twitter.com/damarkuncoro)
|
|
407
|
+
*Build beautiful, consistent, and theme-aware user interfaces with ease.*
|
|
1015
408
|
|
|
1016
|
-
|
|
409
|
+
**Author:** Damar Kuncoro
|
|
410
|
+
**Version:** 0.1.4
|