intent-core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +34 -0
- package/dist/compiler/index.d.ts +53 -0
- package/dist/compiler/index.d.ts.map +1 -0
- package/dist/compiler/index.js +147 -0
- package/dist/compiler/index.js.map +1 -0
- package/dist/compiler/parser.d.ts +25 -0
- package/dist/compiler/parser.d.ts.map +1 -0
- package/dist/compiler/parser.js +198 -0
- package/dist/compiler/parser.js.map +1 -0
- package/dist/generator/ai-manifest.d.ts +14 -0
- package/dist/generator/ai-manifest.d.ts.map +1 -0
- package/dist/generator/ai-manifest.js +276 -0
- package/dist/generator/ai-manifest.js.map +1 -0
- package/dist/generator/css.d.ts +16 -0
- package/dist/generator/css.d.ts.map +1 -0
- package/dist/generator/css.js +230 -0
- package/dist/generator/css.js.map +1 -0
- package/dist/generator/types.d.ts +11 -0
- package/dist/generator/types.d.ts.map +1 -0
- package/dist/generator/types.js +229 -0
- package/dist/generator/types.js.map +1 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/schema/define.d.ts +60 -0
- package/dist/schema/define.d.ts.map +1 -0
- package/dist/schema/define.js +167 -0
- package/dist/schema/define.js.map +1 -0
- package/dist/types/index.d.ts +156 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -0
- package/dist/validator/constraints.d.ts +16 -0
- package/dist/validator/constraints.d.ts.map +1 -0
- package/dist/validator/constraints.js +168 -0
- package/dist/validator/constraints.js.map +1 -0
- package/dist/validator/index.d.ts +22 -0
- package/dist/validator/index.d.ts.map +1 -0
- package/dist/validator/index.js +321 -0
- package/dist/validator/index.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript Type Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates strict TypeScript types from component schemas.
|
|
5
|
+
*/
|
|
6
|
+
import { generateValidCombinations } from '../validator/constraints.js';
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// Type Generation Helpers
|
|
9
|
+
// ============================================================================
|
|
10
|
+
function propertyToTypeScript(propName, prop) {
|
|
11
|
+
const type = getTypeString(prop);
|
|
12
|
+
const optional = isOptional(prop) ? '?' : '';
|
|
13
|
+
return ` ${propName}${optional}: ${type};`;
|
|
14
|
+
}
|
|
15
|
+
function getTypeString(prop) {
|
|
16
|
+
switch (prop.type) {
|
|
17
|
+
case 'enum':
|
|
18
|
+
return prop.values.map(v => `'${v}'`).join(' | ');
|
|
19
|
+
case 'boolean':
|
|
20
|
+
return 'boolean';
|
|
21
|
+
case 'string':
|
|
22
|
+
return 'string';
|
|
23
|
+
case 'number':
|
|
24
|
+
return 'number';
|
|
25
|
+
default:
|
|
26
|
+
return 'unknown';
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function isOptional(prop) {
|
|
30
|
+
return !prop.required;
|
|
31
|
+
}
|
|
32
|
+
function generateJSDoc(schema) {
|
|
33
|
+
const lines = ['/**'];
|
|
34
|
+
if (schema.description) {
|
|
35
|
+
lines.push(` * ${schema.description}`);
|
|
36
|
+
lines.push(' *');
|
|
37
|
+
}
|
|
38
|
+
// Add prop documentation
|
|
39
|
+
for (const [name, prop] of Object.entries(schema.properties)) {
|
|
40
|
+
const type = getTypeString(prop);
|
|
41
|
+
const def = 'default' in prop ? ` (default: ${JSON.stringify(prop.default)})` : '';
|
|
42
|
+
lines.push(` * @property {${type}} ${name}${def}`);
|
|
43
|
+
}
|
|
44
|
+
// Add constraint documentation
|
|
45
|
+
if (schema.constraints.length > 0) {
|
|
46
|
+
lines.push(' *');
|
|
47
|
+
lines.push(' * Constraints:');
|
|
48
|
+
for (const constraint of schema.constraints) {
|
|
49
|
+
const when = Object.entries(constraint.when)
|
|
50
|
+
.map(([k, v]) => `${k}=${JSON.stringify(v)}`)
|
|
51
|
+
.join(', ');
|
|
52
|
+
if (constraint.forbid) {
|
|
53
|
+
lines.push(` * - When ${when}: cannot use ${constraint.forbid.join(', ')}`);
|
|
54
|
+
}
|
|
55
|
+
if (constraint.require) {
|
|
56
|
+
const reqs = Object.entries(constraint.require)
|
|
57
|
+
.map(([k, v]) => `${k} in [${v.join(', ')}]`)
|
|
58
|
+
.join(', ');
|
|
59
|
+
lines.push(` * - When ${when}: requires ${reqs}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
lines.push(' */');
|
|
64
|
+
return lines.join('\n');
|
|
65
|
+
}
|
|
66
|
+
// ============================================================================
|
|
67
|
+
// Component Type Generation
|
|
68
|
+
// ============================================================================
|
|
69
|
+
export function generateComponentTypes(schema) {
|
|
70
|
+
const lines = [];
|
|
71
|
+
const componentName = schema.name;
|
|
72
|
+
const propsName = `${componentName}Props`;
|
|
73
|
+
// JSDoc
|
|
74
|
+
lines.push(generateJSDoc(schema));
|
|
75
|
+
// Props interface
|
|
76
|
+
lines.push(`export interface ${propsName} {`);
|
|
77
|
+
for (const [propName, prop] of Object.entries(schema.properties)) {
|
|
78
|
+
lines.push(propertyToTypeScript(propName, prop));
|
|
79
|
+
}
|
|
80
|
+
// Add HTML props extension point
|
|
81
|
+
lines.push(` // HTML attributes are filtered - only Intent props allowed`);
|
|
82
|
+
lines.push(` [key: string]: unknown;`);
|
|
83
|
+
lines.push('}');
|
|
84
|
+
lines.push('');
|
|
85
|
+
// Valid combinations type (for advanced use)
|
|
86
|
+
const combinations = generateValidCombinations(schema);
|
|
87
|
+
if (combinations.length > 0 && combinations.length <= 20) {
|
|
88
|
+
lines.push(`/** Valid prop combinations for ${componentName} */`);
|
|
89
|
+
lines.push(`export type ${componentName}ValidCombinations =`);
|
|
90
|
+
const comboStrings = combinations.map(combo => {
|
|
91
|
+
const props = Object.entries(combo)
|
|
92
|
+
.map(([k, v]) => `${k}: '${v}'`)
|
|
93
|
+
.join('; ');
|
|
94
|
+
return ` | { ${props} }`;
|
|
95
|
+
});
|
|
96
|
+
lines.push(comboStrings.join('\n'));
|
|
97
|
+
lines.push(';');
|
|
98
|
+
lines.push('');
|
|
99
|
+
}
|
|
100
|
+
return lines.join('\n');
|
|
101
|
+
}
|
|
102
|
+
// ============================================================================
|
|
103
|
+
// Token Type Generation
|
|
104
|
+
// ============================================================================
|
|
105
|
+
export function generateTokenTypes(tokens) {
|
|
106
|
+
const lines = [];
|
|
107
|
+
lines.push('/** Design Tokens */');
|
|
108
|
+
lines.push('');
|
|
109
|
+
for (const [category, values] of Object.entries(tokens)) {
|
|
110
|
+
if (!values || Object.keys(values).length === 0)
|
|
111
|
+
continue;
|
|
112
|
+
const typeName = `${capitalize(category)}Token`;
|
|
113
|
+
const keys = Object.keys(values);
|
|
114
|
+
lines.push(`/** Valid ${category} tokens */`);
|
|
115
|
+
lines.push(`export type ${typeName} =`);
|
|
116
|
+
keys.forEach((key, i) => {
|
|
117
|
+
const sep = i < keys.length - 1 ? ' |' : ';';
|
|
118
|
+
lines.push(` | '${key}'${sep}`);
|
|
119
|
+
});
|
|
120
|
+
lines.push('');
|
|
121
|
+
}
|
|
122
|
+
// Token registry type
|
|
123
|
+
lines.push('/** Complete token registry */');
|
|
124
|
+
lines.push('export interface TokenRegistry {');
|
|
125
|
+
for (const category of Object.keys(tokens)) {
|
|
126
|
+
if (tokens[category]) {
|
|
127
|
+
lines.push(` ${category}: ${capitalize(category)}Token;`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
lines.push('}');
|
|
131
|
+
lines.push('');
|
|
132
|
+
return lines.join('\n');
|
|
133
|
+
}
|
|
134
|
+
// ============================================================================
|
|
135
|
+
// Full System Type Generation
|
|
136
|
+
// ============================================================================
|
|
137
|
+
export function generateSystemTypes(config) {
|
|
138
|
+
const lines = [];
|
|
139
|
+
// Header
|
|
140
|
+
lines.push(`// Generated by Intent v${config.version || '0.1.0'}`);
|
|
141
|
+
lines.push(`// Design System: ${config.name}`);
|
|
142
|
+
lines.push('');
|
|
143
|
+
lines.push('/* eslint-disable */');
|
|
144
|
+
lines.push('// @ts-nocheck');
|
|
145
|
+
lines.push('');
|
|
146
|
+
// Token types
|
|
147
|
+
lines.push('// ============================================================================');
|
|
148
|
+
lines.push('// TOKENS');
|
|
149
|
+
lines.push('// ============================================================================');
|
|
150
|
+
lines.push('');
|
|
151
|
+
lines.push(generateTokenTypes(config.tokens));
|
|
152
|
+
// Component types
|
|
153
|
+
lines.push('// ============================================================================');
|
|
154
|
+
lines.push('// COMPONENTS');
|
|
155
|
+
lines.push('// ============================================================================');
|
|
156
|
+
lines.push('');
|
|
157
|
+
const componentImports = [];
|
|
158
|
+
const componentExports = [];
|
|
159
|
+
for (const [name, schema] of Object.entries(config.components)) {
|
|
160
|
+
lines.push(generateComponentTypes(schema));
|
|
161
|
+
componentImports.push(`${name}Props`);
|
|
162
|
+
componentExports.push(name);
|
|
163
|
+
}
|
|
164
|
+
// Component registry
|
|
165
|
+
lines.push('// ============================================================================');
|
|
166
|
+
lines.push('// COMPONENT REGISTRY');
|
|
167
|
+
lines.push('// ============================================================================');
|
|
168
|
+
lines.push('');
|
|
169
|
+
lines.push('/** All available Intent components */');
|
|
170
|
+
lines.push(`export type IntentComponent =`);
|
|
171
|
+
componentExports.forEach((name, i) => {
|
|
172
|
+
const sep = i < componentExports.length - 1 ? ' |' : ';';
|
|
173
|
+
lines.push(` | '${name}'${sep}`);
|
|
174
|
+
});
|
|
175
|
+
lines.push('');
|
|
176
|
+
lines.push('/** Props for each component */');
|
|
177
|
+
lines.push('export interface IntentProps {');
|
|
178
|
+
for (const name of componentExports) {
|
|
179
|
+
lines.push(` ${name}: ${name}Props;`);
|
|
180
|
+
}
|
|
181
|
+
lines.push('}');
|
|
182
|
+
lines.push('');
|
|
183
|
+
// Re-exports
|
|
184
|
+
lines.push('// ============================================================================');
|
|
185
|
+
lines.push('// RE-EXPORTS');
|
|
186
|
+
lines.push('// ============================================================================');
|
|
187
|
+
lines.push('');
|
|
188
|
+
lines.push(`export type { ${componentImports.join(', ')} };`);
|
|
189
|
+
lines.push('');
|
|
190
|
+
return lines.join('\n');
|
|
191
|
+
}
|
|
192
|
+
// ============================================================================
|
|
193
|
+
// Runtime Validation Types
|
|
194
|
+
// ============================================================================
|
|
195
|
+
export function generateRuntimeTypes(config) {
|
|
196
|
+
const lines = [];
|
|
197
|
+
lines.push('/** Runtime schema definitions for validation */');
|
|
198
|
+
lines.push('');
|
|
199
|
+
lines.push('export const INTENT_SCHEMA = {');
|
|
200
|
+
lines.push(` name: '${config.name}',`);
|
|
201
|
+
lines.push(` version: '${config.version || '0.1.0'}',`);
|
|
202
|
+
lines.push(' tokens: ' + JSON.stringify(config.tokens, null, 2).replace(/\n/g, '\n ') + ',');
|
|
203
|
+
lines.push(' components: {');
|
|
204
|
+
for (const [name, schema] of Object.entries(config.components)) {
|
|
205
|
+
lines.push(` ${name}: {`);
|
|
206
|
+
lines.push(` name: '${schema.name}',`);
|
|
207
|
+
lines.push(` description: '${schema.description || ''}',`);
|
|
208
|
+
lines.push(' properties: {');
|
|
209
|
+
for (const [propName, prop] of Object.entries(schema.properties)) {
|
|
210
|
+
lines.push(` ${propName}: ${JSON.stringify(prop)},`);
|
|
211
|
+
}
|
|
212
|
+
lines.push(' },');
|
|
213
|
+
lines.push(` constraints: ${JSON.stringify(schema.constraints)},`);
|
|
214
|
+
lines.push(' },');
|
|
215
|
+
}
|
|
216
|
+
lines.push(' },');
|
|
217
|
+
lines.push('} as const;');
|
|
218
|
+
lines.push('');
|
|
219
|
+
lines.push('export type IntentSchema = typeof INTENT_SCHEMA;');
|
|
220
|
+
lines.push('');
|
|
221
|
+
return lines.join('\n');
|
|
222
|
+
}
|
|
223
|
+
// ============================================================================
|
|
224
|
+
// Utility
|
|
225
|
+
// ============================================================================
|
|
226
|
+
function capitalize(str) {
|
|
227
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
228
|
+
}
|
|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|
|
7
|
+
* ```ts
|
|
8
|
+
* import { defineSystem, defineComponent, prop, when } from 'intent-core';
|
|
9
|
+
*
|
|
10
|
+
* const designSystem = defineSystem({
|
|
11
|
+
* name: 'MyDesignSystem',
|
|
12
|
+
* tokens: {
|
|
13
|
+
* color: {
|
|
14
|
+
* 'brand-primary': '#3B82F6',
|
|
15
|
+
* 'brand-secondary': '#64748B',
|
|
16
|
+
* },
|
|
17
|
+
* },
|
|
18
|
+
* components: {
|
|
19
|
+
* Button: defineComponent({
|
|
20
|
+
* name: 'Button',
|
|
21
|
+
* properties: {
|
|
22
|
+
* importance: prop.enum(['primary', 'secondary'], { required: true }),
|
|
23
|
+
* size: prop.enum(['sm', 'md', 'lg'], { default: 'md' }),
|
|
24
|
+
* },
|
|
25
|
+
* constraints: [
|
|
26
|
+
* when({ importance: 'ghost' }).forbid(['disabled']),
|
|
27
|
+
* ],
|
|
28
|
+
* mappings: {
|
|
29
|
+
* 'importance=primary': { background: 'brand-primary' },
|
|
30
|
+
* },
|
|
31
|
+
* }),
|
|
32
|
+
* },
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export { defineSystem, defineComponent, prop, when, forbid, require, } from './schema/define.js';
|
|
37
|
+
export { validateSchema, validateUsage, validateAllUsages, } from './validator/index.js';
|
|
38
|
+
export { validateConstraints, generateValidCombinations, suggestValidAlternatives, } from './validator/constraints.js';
|
|
39
|
+
export { compileComponent, compileSystem, generateCSSVariables, generateDarkModeVariables, } from './generator/css.js';
|
|
40
|
+
export { generateComponentTypes, generateTokenTypes, generateSystemTypes, generateRuntimeTypes, } from './generator/types.js';
|
|
41
|
+
export { generateAIManifest, generateAIPrompt, } from './generator/ai-manifest.js';
|
|
42
|
+
export { parseFile, parseFiles, parseSourceFile, } from './compiler/parser.js';
|
|
43
|
+
export type { TokenValue, TokenCategory, TokenRegistry, PropertyType, EnumProperty, BooleanProperty, StringProperty, NumberProperty, PropertyDefinition, PropertySet, ConstraintOperator, ConstraintCondition, ConstraintAction, Constraint, CSSProperty, TokenReference, StyleValue, VisualMapping, ConditionalMapping, ComponentSchema, DesignSystemConfig, DesignSystem, ValidationSeverity, ValidationIssue, ValidationResult, ComponentUsage, CompiledStyles, ComponentCompilation, CompilationOutput, ComponentSchemaForAI, AIManifest, } from './types/index.js';
|
|
44
|
+
export type { ParseOptions, ParsedResult, BatchParseResult, } from './compiler/parser.js';
|
|
45
|
+
export type { ValidatorOptions, UsageValidationContext, BatchUsage, } from './validator/index.js';
|
|
46
|
+
export declare const VERSION = "0.1.0";
|
|
47
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAGH,OAAO,EACL,YAAY,EACZ,eAAe,EACf,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,OAAO,GACR,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,cAAc,EACd,aAAa,EACb,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACL,SAAS,EACT,UAAU,EACV,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAG9B,YAAY,EAEV,UAAU,EACV,aAAa,EACb,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,WAAW,EAGX,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,UAAU,EAGV,WAAW,EACX,cAAc,EACd,UAAU,EACV,aAAa,EACb,kBAAkB,EAGlB,eAAe,EACf,kBAAkB,EAClB,YAAY,EAGZ,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,cAAc,EAGd,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EAGjB,oBAAoB,EACpB,UAAU,GACX,MAAM,kBAAkB,CAAC;AAG1B,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAG9B,YAAY,EACV,gBAAgB,EAChB,sBAAsB,EACtB,UAAU,GACX,MAAM,sBAAsB,CAAC;AAG9B,eAAO,MAAM,OAAO,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Intent Core
|
|
3
|
+
*
|
|
4
|
+
* Schema-first, AI-native styling framework core.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { defineSystem, defineComponent, prop, when } from 'intent-core';
|
|
9
|
+
*
|
|
10
|
+
* const designSystem = defineSystem({
|
|
11
|
+
* name: 'MyDesignSystem',
|
|
12
|
+
* tokens: {
|
|
13
|
+
* color: {
|
|
14
|
+
* 'brand-primary': '#3B82F6',
|
|
15
|
+
* 'brand-secondary': '#64748B',
|
|
16
|
+
* },
|
|
17
|
+
* },
|
|
18
|
+
* components: {
|
|
19
|
+
* Button: defineComponent({
|
|
20
|
+
* name: 'Button',
|
|
21
|
+
* properties: {
|
|
22
|
+
* importance: prop.enum(['primary', 'secondary'], { required: true }),
|
|
23
|
+
* size: prop.enum(['sm', 'md', 'lg'], { default: 'md' }),
|
|
24
|
+
* },
|
|
25
|
+
* constraints: [
|
|
26
|
+
* when({ importance: 'ghost' }).forbid(['disabled']),
|
|
27
|
+
* ],
|
|
28
|
+
* mappings: {
|
|
29
|
+
* 'importance=primary': { background: 'brand-primary' },
|
|
30
|
+
* },
|
|
31
|
+
* }),
|
|
32
|
+
* },
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
// Schema Definition
|
|
37
|
+
export { defineSystem, defineComponent, prop, when, forbid, require, } from './schema/define.js';
|
|
38
|
+
// Validation
|
|
39
|
+
export { validateSchema, validateUsage, validateAllUsages, } from './validator/index.js';
|
|
40
|
+
export { validateConstraints, generateValidCombinations, suggestValidAlternatives, } from './validator/constraints.js';
|
|
41
|
+
// CSS Generation
|
|
42
|
+
export { compileComponent, compileSystem, generateCSSVariables, generateDarkModeVariables, } from './generator/css.js';
|
|
43
|
+
// Type Generation
|
|
44
|
+
export { generateComponentTypes, generateTokenTypes, generateSystemTypes, generateRuntimeTypes, } from './generator/types.js';
|
|
45
|
+
// AI Manifest
|
|
46
|
+
export { generateAIManifest, generateAIPrompt, } from './generator/ai-manifest.js';
|
|
47
|
+
// Parser
|
|
48
|
+
export { parseFile, parseFiles, parseSourceFile, } from './compiler/parser.js';
|
|
49
|
+
// Version
|
|
50
|
+
export const VERSION = '0.1.0';
|
|
51
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,oBAAoB;AACpB,OAAO,EACL,YAAY,EACZ,eAAe,EACf,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,OAAO,GACR,MAAM,oBAAoB,CAAC;AAE5B,aAAa;AACb,OAAO,EACL,cAAc,EACd,aAAa,EACb,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,4BAA4B,CAAC;AAEpC,iBAAiB;AACjB,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC;AAE5B,kBAAkB;AAClB,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAE9B,cAAc;AACd,OAAO,EACL,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,4BAA4B,CAAC;AAEpC,SAAS;AACT,OAAO,EACL,SAAS,EACT,UAAU,EACV,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAgE9B,UAAU;AACV,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema Definition DSL
|
|
3
|
+
*
|
|
4
|
+
* Provides the `defineSystem` and `defineComponent` functions for creating
|
|
5
|
+
* type-safe, constraint-based design systems.
|
|
6
|
+
*/
|
|
7
|
+
import type { DesignSystemConfig, ComponentSchema, TokenRegistry, PropertySet, Constraint, VisualMapping, ConditionalMapping } from '../types/index.js';
|
|
8
|
+
declare class ComponentBuilder {
|
|
9
|
+
private schema;
|
|
10
|
+
name(name: string): this;
|
|
11
|
+
description(desc: string): this;
|
|
12
|
+
properties(props: PropertySet): this;
|
|
13
|
+
constrain(...constraints: Constraint[]): this;
|
|
14
|
+
map(mappings: Record<string, VisualMapping | ConditionalMapping[]>): this;
|
|
15
|
+
base(styles: VisualMapping): this;
|
|
16
|
+
build(): ComponentSchema;
|
|
17
|
+
}
|
|
18
|
+
export declare function defineComponent(config: (builder: ComponentBuilder) => ComponentBuilder): ComponentSchema;
|
|
19
|
+
export declare function defineComponent(config: Partial<ComponentSchema>): ComponentSchema;
|
|
20
|
+
declare class SystemBuilder {
|
|
21
|
+
private config;
|
|
22
|
+
name(name: string): this;
|
|
23
|
+
version(version: string): this;
|
|
24
|
+
tokens(tokens: TokenRegistry): this;
|
|
25
|
+
component(name: string, schema: ComponentSchema | ((builder: ComponentBuilder) => ComponentBuilder)): this;
|
|
26
|
+
settings(settings: DesignSystemConfig['settings']): this;
|
|
27
|
+
build(): DesignSystemConfig;
|
|
28
|
+
}
|
|
29
|
+
export declare function defineSystem(config: (builder: SystemBuilder) => SystemBuilder): DesignSystemConfig;
|
|
30
|
+
export declare function defineSystem(config: Omit<DesignSystemConfig, 'components'> & {
|
|
31
|
+
components: Record<string, ComponentSchema>;
|
|
32
|
+
}): DesignSystemConfig;
|
|
33
|
+
export declare const prop: {
|
|
34
|
+
enum: (values: string[], config?: {
|
|
35
|
+
required?: boolean;
|
|
36
|
+
default?: string;
|
|
37
|
+
}) => import("../types/index.js").EnumProperty;
|
|
38
|
+
boolean: (config?: {
|
|
39
|
+
required?: boolean;
|
|
40
|
+
default?: boolean;
|
|
41
|
+
}) => import("../types/index.js").BooleanProperty;
|
|
42
|
+
string: (config?: {
|
|
43
|
+
required?: boolean;
|
|
44
|
+
default?: string;
|
|
45
|
+
}) => import("../types/index.js").StringProperty;
|
|
46
|
+
number: (config?: {
|
|
47
|
+
required?: boolean;
|
|
48
|
+
default?: number;
|
|
49
|
+
min?: number;
|
|
50
|
+
max?: number;
|
|
51
|
+
}) => import("../types/index.js").NumberProperty;
|
|
52
|
+
};
|
|
53
|
+
export declare function when(condition: Record<string, string | string[]>): {
|
|
54
|
+
forbid: (props: string[], message?: string) => Constraint;
|
|
55
|
+
require: (requirements: Record<string, string[]>, message?: string) => Constraint;
|
|
56
|
+
};
|
|
57
|
+
export declare function forbid(props: string[], message?: string): Omit<Constraint, 'when'>;
|
|
58
|
+
export declare function require(requirements: Record<string, string[]>, message?: string): Omit<Constraint, 'when'>;
|
|
59
|
+
export {};
|
|
60
|
+
//# sourceMappingURL=define.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../../src/schema/define.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,kB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AAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAKlF;AAED,wBAAgB,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAK1G"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schema Definition DSL
|
|
3
|
+
*
|
|
4
|
+
* Provides the `defineSystem` and `defineComponent` functions for creating
|
|
5
|
+
* type-safe, constraint-based design systems.
|
|
6
|
+
*/
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// Component Builder
|
|
9
|
+
// ============================================================================
|
|
10
|
+
class ComponentBuilder {
|
|
11
|
+
schema = {
|
|
12
|
+
constraints: [],
|
|
13
|
+
mappings: {},
|
|
14
|
+
};
|
|
15
|
+
name(name) {
|
|
16
|
+
this.schema.name = name;
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
description(desc) {
|
|
20
|
+
this.schema.description = desc;
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
properties(props) {
|
|
24
|
+
this.schema.properties = props;
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
constrain(...constraints) {
|
|
28
|
+
this.schema.constraints = [...(this.schema.constraints || []), ...constraints];
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
map(mappings) {
|
|
32
|
+
this.schema.mappings = mappings;
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
base(styles) {
|
|
36
|
+
this.schema.baseStyles = styles;
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
build() {
|
|
40
|
+
if (!this.schema.name) {
|
|
41
|
+
throw new Error('Component must have a name');
|
|
42
|
+
}
|
|
43
|
+
if (!this.schema.properties) {
|
|
44
|
+
throw new Error(`Component "${this.schema.name}" must define properties`);
|
|
45
|
+
}
|
|
46
|
+
return this.schema;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export function defineComponent(config) {
|
|
50
|
+
if (typeof config === 'function') {
|
|
51
|
+
const builder = new ComponentBuilder();
|
|
52
|
+
return config(builder).build();
|
|
53
|
+
}
|
|
54
|
+
// Direct object configuration
|
|
55
|
+
if (!config.name) {
|
|
56
|
+
throw new Error('Component must have a name');
|
|
57
|
+
}
|
|
58
|
+
if (!config.properties) {
|
|
59
|
+
throw new Error(`Component "${config.name}" must define properties`);
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
constraints: [],
|
|
63
|
+
mappings: {},
|
|
64
|
+
...config,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
class SystemBuilder {
|
|
68
|
+
config = {
|
|
69
|
+
name: '',
|
|
70
|
+
tokens: {},
|
|
71
|
+
components: {},
|
|
72
|
+
};
|
|
73
|
+
name(name) {
|
|
74
|
+
this.config.name = name;
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
version(version) {
|
|
78
|
+
this.config.version = version;
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
tokens(tokens) {
|
|
82
|
+
this.config.tokens = tokens;
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
component(name, schema) {
|
|
86
|
+
const resolvedSchema = typeof schema === 'function'
|
|
87
|
+
? schema(new ComponentBuilder().name(name)).build()
|
|
88
|
+
: schema;
|
|
89
|
+
this.config.components[name] = resolvedSchema;
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
settings(settings) {
|
|
93
|
+
this.config.settings = settings;
|
|
94
|
+
return this;
|
|
95
|
+
}
|
|
96
|
+
build() {
|
|
97
|
+
if (!this.config.name) {
|
|
98
|
+
throw new Error('Design system must have a name');
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
name: this.config.name,
|
|
102
|
+
version: this.config.version,
|
|
103
|
+
tokens: this.config.tokens,
|
|
104
|
+
components: this.config.components,
|
|
105
|
+
settings: this.config.settings,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
export function defineSystem(config) {
|
|
110
|
+
if (typeof config === 'function') {
|
|
111
|
+
const builder = new SystemBuilder();
|
|
112
|
+
return config(builder).build();
|
|
113
|
+
}
|
|
114
|
+
return config;
|
|
115
|
+
}
|
|
116
|
+
// ============================================================================
|
|
117
|
+
// Property Helpers
|
|
118
|
+
// ============================================================================
|
|
119
|
+
export const prop = {
|
|
120
|
+
enum: (values, config = {}) => ({
|
|
121
|
+
type: 'enum',
|
|
122
|
+
values,
|
|
123
|
+
...config,
|
|
124
|
+
}),
|
|
125
|
+
boolean: (config = {}) => ({
|
|
126
|
+
type: 'boolean',
|
|
127
|
+
...config,
|
|
128
|
+
}),
|
|
129
|
+
string: (config = {}) => ({
|
|
130
|
+
type: 'string',
|
|
131
|
+
...config,
|
|
132
|
+
}),
|
|
133
|
+
number: (config = {}) => ({
|
|
134
|
+
type: 'number',
|
|
135
|
+
...config,
|
|
136
|
+
}),
|
|
137
|
+
};
|
|
138
|
+
// ============================================================================
|
|
139
|
+
// Constraint Helpers
|
|
140
|
+
// ============================================================================
|
|
141
|
+
export function when(condition) {
|
|
142
|
+
return {
|
|
143
|
+
forbid: (props, message) => ({
|
|
144
|
+
when: condition,
|
|
145
|
+
forbid: props,
|
|
146
|
+
message,
|
|
147
|
+
}),
|
|
148
|
+
require: (requirements, message) => ({
|
|
149
|
+
when: condition,
|
|
150
|
+
require: requirements,
|
|
151
|
+
message,
|
|
152
|
+
}),
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
export function forbid(props, message) {
|
|
156
|
+
return {
|
|
157
|
+
forbid: props,
|
|
158
|
+
message,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
export function require(requirements, message) {
|
|
162
|
+
return {
|
|
163
|
+
require: requirements,
|
|
164
|
+
message,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=define.js.map
|
|
@@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