meno-core 1.0.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/bin/cli.ts +281 -0
- package/build-static.ts +298 -0
- package/bunfig.toml +39 -0
- package/entries/client-router.tsx +111 -0
- package/entries/server-router.tsx +71 -0
- package/lib/client/ClientInitializer.test.ts +9 -0
- package/lib/client/ClientInitializer.test.ts.skip +92 -0
- package/lib/client/ClientInitializer.ts +60 -0
- package/lib/client/ErrorBoundary.test.tsx +595 -0
- package/lib/client/ErrorBoundary.tsx +230 -0
- package/lib/client/componentRegistry.test.ts +165 -0
- package/lib/client/componentRegistry.ts +18 -0
- package/lib/client/contexts/ThemeContext.tsx +73 -0
- package/lib/client/core/ComponentBuilder.test.ts +677 -0
- package/lib/client/core/ComponentBuilder.ts +660 -0
- package/lib/client/core/ComponentRenderer.test.tsx +176 -0
- package/lib/client/core/ComponentRenderer.tsx +83 -0
- package/lib/client/core/cmsTemplateProcessor.ts +129 -0
- package/lib/client/elementRegistry.ts +81 -0
- package/lib/client/hmr/HMRManager.tsx +179 -0
- package/lib/client/hmr/index.ts +5 -0
- package/lib/client/hmrWebSocket.test.ts +9 -0
- package/lib/client/hmrWebSocket.ts +250 -0
- package/lib/client/hooks/useColorVariables.test.ts +166 -0
- package/lib/client/hooks/useColorVariables.ts +249 -0
- package/lib/client/hooks/usePropertyAutocomplete.test.ts +9 -0
- package/lib/client/hooks/usePropertyAutocomplete.ts +40 -0
- package/lib/client/hydration/HydrationUtils.test.ts +154 -0
- package/lib/client/hydration/HydrationUtils.ts +35 -0
- package/lib/client/i18nConfigService.test.ts +74 -0
- package/lib/client/i18nConfigService.ts +78 -0
- package/lib/client/index.ts +56 -0
- package/lib/client/navigation.test.ts +441 -0
- package/lib/client/navigation.ts +23 -0
- package/lib/client/responsiveStyleResolver.test.ts +491 -0
- package/lib/client/responsiveStyleResolver.ts +184 -0
- package/lib/client/routing/RouteLoader.test.ts +635 -0
- package/lib/client/routing/RouteLoader.ts +347 -0
- package/lib/client/routing/Router.tsx +382 -0
- package/lib/client/scripts/ScriptExecutor.test.ts +489 -0
- package/lib/client/scripts/ScriptExecutor.ts +171 -0
- package/lib/client/scripts/formHandler.ts +103 -0
- package/lib/client/styleProcessor.test.ts +126 -0
- package/lib/client/styleProcessor.ts +92 -0
- package/lib/client/styles/StyleInjector.test.ts +354 -0
- package/lib/client/styles/StyleInjector.ts +154 -0
- package/lib/client/templateEngine.test.ts +660 -0
- package/lib/client/templateEngine.ts +667 -0
- package/lib/client/theme.test.ts +173 -0
- package/lib/client/theme.ts +159 -0
- package/lib/client/utils/toast.ts +46 -0
- package/lib/server/createServer.ts +170 -0
- package/lib/server/cssGenerator.test.ts +172 -0
- package/lib/server/cssGenerator.ts +58 -0
- package/lib/server/fileWatcher.ts +134 -0
- package/lib/server/index.ts +55 -0
- package/lib/server/jsonLoader.test.ts +103 -0
- package/lib/server/jsonLoader.ts +350 -0
- package/lib/server/middleware/cors.test.ts +177 -0
- package/lib/server/middleware/cors.ts +69 -0
- package/lib/server/middleware/errorHandler.test.ts +208 -0
- package/lib/server/middleware/errorHandler.ts +63 -0
- package/lib/server/middleware/index.ts +9 -0
- package/lib/server/middleware/logger.test.ts +233 -0
- package/lib/server/middleware/logger.ts +99 -0
- package/lib/server/pageCache.test.ts +167 -0
- package/lib/server/pageCache.ts +97 -0
- package/lib/server/projectContext.ts +51 -0
- package/lib/server/providers/fileSystemCMSProvider.test.ts +292 -0
- package/lib/server/providers/fileSystemCMSProvider.ts +227 -0
- package/lib/server/providers/fileSystemPageProvider.ts +83 -0
- package/lib/server/routes/api/cms.test.ts +177 -0
- package/lib/server/routes/api/cms.ts +82 -0
- package/lib/server/routes/api/colors.ts +59 -0
- package/lib/server/routes/api/components.ts +70 -0
- package/lib/server/routes/api/config.test.ts +9 -0
- package/lib/server/routes/api/config.ts +28 -0
- package/lib/server/routes/api/core-routes.ts +182 -0
- package/lib/server/routes/api/functions.ts +170 -0
- package/lib/server/routes/api/index.ts +69 -0
- package/lib/server/routes/api/pages.ts +95 -0
- package/lib/server/routes/api/shared.test.ts +81 -0
- package/lib/server/routes/api/shared.ts +31 -0
- package/lib/server/routes/editor.test.ts +9 -0
- package/lib/server/routes/index.ts +104 -0
- package/lib/server/routes/pages.ts +161 -0
- package/lib/server/routes/static.ts +107 -0
- package/lib/server/services/ColorService.ts +193 -0
- package/lib/server/services/cmsService.test.ts +388 -0
- package/lib/server/services/cmsService.ts +296 -0
- package/lib/server/services/componentService.test.ts +276 -0
- package/lib/server/services/componentService.ts +346 -0
- package/lib/server/services/configService.ts +156 -0
- package/lib/server/services/fileWatcherService.ts +67 -0
- package/lib/server/services/index.ts +10 -0
- package/lib/server/services/pageService.test.ts +258 -0
- package/lib/server/services/pageService.ts +240 -0
- package/lib/server/ssrRenderer.test.ts +1005 -0
- package/lib/server/ssrRenderer.ts +878 -0
- package/lib/server/utilityClassGenerator.ts +11 -0
- package/lib/server/utils/index.ts +5 -0
- package/lib/server/utils/jsonLineMapper.test.ts +100 -0
- package/lib/server/utils/jsonLineMapper.ts +166 -0
- package/lib/server/validateStyleCoverage.test.ts +9 -0
- package/lib/server/validateStyleCoverage.ts +167 -0
- package/lib/server/websocketManager.test.ts +9 -0
- package/lib/server/websocketManager.ts +95 -0
- package/lib/shared/attributeNodeUtils.test.ts +152 -0
- package/lib/shared/attributeNodeUtils.ts +50 -0
- package/lib/shared/breakpoints.test.ts +166 -0
- package/lib/shared/breakpoints.ts +65 -0
- package/lib/shared/colorProperties.test.ts +111 -0
- package/lib/shared/colorProperties.ts +40 -0
- package/lib/shared/colorVariableUtils.test.ts +319 -0
- package/lib/shared/colorVariableUtils.ts +97 -0
- package/lib/shared/constants.test.ts +175 -0
- package/lib/shared/constants.ts +116 -0
- package/lib/shared/cssGeneration.ts +481 -0
- package/lib/shared/cssProperties.test.ts +252 -0
- package/lib/shared/cssProperties.ts +338 -0
- package/lib/shared/elementUtils.test.ts +245 -0
- package/lib/shared/elementUtils.ts +90 -0
- package/lib/shared/fontLoader.ts +97 -0
- package/lib/shared/i18n.test.ts +313 -0
- package/lib/shared/i18n.ts +286 -0
- package/lib/shared/index.ts +50 -0
- package/lib/shared/interfaces/contentProvider.test.ts +9 -0
- package/lib/shared/interfaces/contentProvider.ts +121 -0
- package/lib/shared/nodeUtils.test.ts +320 -0
- package/lib/shared/nodeUtils.ts +220 -0
- package/lib/shared/pathArrayUtils.test.ts +315 -0
- package/lib/shared/pathArrayUtils.ts +17 -0
- package/lib/shared/pathUtils.test.ts +260 -0
- package/lib/shared/pathUtils.ts +244 -0
- package/lib/shared/paths/Path.test.ts +74 -0
- package/lib/shared/paths/Path.ts +23 -0
- package/lib/shared/paths/PathConverter.test.ts +232 -0
- package/lib/shared/paths/PathConverter.ts +141 -0
- package/lib/shared/paths/PathUtils.ts +290 -0
- package/lib/shared/paths/PathValidator.test.ts +193 -0
- package/lib/shared/paths/PathValidator.ts +53 -0
- package/lib/shared/paths/index.ts +48 -0
- package/lib/shared/propResolver.test.ts +639 -0
- package/lib/shared/propResolver.ts +124 -0
- package/lib/shared/registry/BaseNodeTypeRegistry.test.ts +190 -0
- package/lib/shared/registry/BaseNodeTypeRegistry.ts +200 -0
- package/lib/shared/registry/ClientNodeTypeRegistry.ts +34 -0
- package/lib/shared/registry/ClientRegistry.test.ts +26 -0
- package/lib/shared/registry/ClientRegistry.ts +15 -0
- package/lib/shared/registry/ComponentRegistry.test.ts +293 -0
- package/lib/shared/registry/ComponentRegistry.ts +100 -0
- package/lib/shared/registry/NodeTypeDefinition.ts +198 -0
- package/lib/shared/registry/NodeTypeManager.ts +94 -0
- package/lib/shared/registry/RegistryManager.test.ts +58 -0
- package/lib/shared/registry/RegistryManager.ts +60 -0
- package/lib/shared/registry/SSRNodeTypeRegistry.ts +33 -0
- package/lib/shared/registry/SSRRegistry.test.ts +26 -0
- package/lib/shared/registry/SSRRegistry.ts +15 -0
- package/lib/shared/registry/createNodeType.ts +175 -0
- package/lib/shared/registry/defineNodeType.ts +73 -0
- package/lib/shared/registry/fieldPresets.ts +109 -0
- package/lib/shared/registry/index.ts +50 -0
- package/lib/shared/registry/nodeTypes/ComponentInstanceNodeType.ts +71 -0
- package/lib/shared/registry/nodeTypes/EmbedNodeType.ts +61 -0
- package/lib/shared/registry/nodeTypes/HtmlNodeType.ts +88 -0
- package/lib/shared/registry/nodeTypes/LocaleListNodeType.ts +66 -0
- package/lib/shared/registry/nodeTypes/ObjectLinkNodeType.ts +75 -0
- package/lib/shared/registry/nodeTypes/SlotMarkerType.ts +49 -0
- package/lib/shared/registry/nodeTypes/TextNodeType.ts +52 -0
- package/lib/shared/registry/nodeTypes/index.ts +75 -0
- package/lib/shared/responsiveScaling.test.ts +268 -0
- package/lib/shared/responsiveScaling.ts +194 -0
- package/lib/shared/responsiveStyleUtils.test.ts +300 -0
- package/lib/shared/responsiveStyleUtils.ts +139 -0
- package/lib/shared/slugTranslator.test.ts +325 -0
- package/lib/shared/slugTranslator.ts +177 -0
- package/lib/shared/styleNodeUtils.test.ts +132 -0
- package/lib/shared/styleNodeUtils.ts +102 -0
- package/lib/shared/styleUtils.test.ts +238 -0
- package/lib/shared/styleUtils.ts +63 -0
- package/lib/shared/themeDefaults.test.ts +113 -0
- package/lib/shared/themeDefaults.ts +103 -0
- package/lib/shared/tree/PathBuilder.ts +383 -0
- package/lib/shared/treePathUtils.test.ts +539 -0
- package/lib/shared/treePathUtils.ts +339 -0
- package/lib/shared/types/api.ts +58 -0
- package/lib/shared/types/cms.ts +95 -0
- package/lib/shared/types/colors.ts +45 -0
- package/lib/shared/types/components.ts +121 -0
- package/lib/shared/types/errors.test.ts +103 -0
- package/lib/shared/types/errors.ts +69 -0
- package/lib/shared/types/index.ts +96 -0
- package/lib/shared/types/nodes.ts +20 -0
- package/lib/shared/types/rendering.ts +61 -0
- package/lib/shared/types/styles.ts +38 -0
- package/lib/shared/types.ts +11 -0
- package/lib/shared/utilityClassConfig.ts +287 -0
- package/lib/shared/utilityClassMapper.test.ts +140 -0
- package/lib/shared/utilityClassMapper.ts +229 -0
- package/lib/shared/utils/fileUtils.test.ts +99 -0
- package/lib/shared/utils/fileUtils.ts +56 -0
- package/lib/shared/utils.test.ts +261 -0
- package/lib/shared/utils.ts +84 -0
- package/lib/shared/validation/index.ts +7 -0
- package/lib/shared/validation/propValidator.test.ts +178 -0
- package/lib/shared/validation/propValidator.ts +238 -0
- package/lib/shared/validation/schemas.test.ts +177 -0
- package/lib/shared/validation/schemas.ts +401 -0
- package/lib/shared/validation/validators.test.ts +109 -0
- package/lib/shared/validation/validators.ts +304 -0
- package/lib/test-utils/dom-setup.ts +55 -0
- package/lib/test-utils/factories/ConsoleMockFactory.ts +200 -0
- package/lib/test-utils/factories/DomMockFactory.ts +487 -0
- package/lib/test-utils/factories/EventMockFactory.ts +244 -0
- package/lib/test-utils/factories/FetchMockFactory.ts +210 -0
- package/lib/test-utils/factories/ServerMockFactory.ts +223 -0
- package/lib/test-utils/factories/StoreMockFactory.ts +370 -0
- package/lib/test-utils/factories/index.ts +11 -0
- package/lib/test-utils/fixtures.ts +134 -0
- package/lib/test-utils/helpers/asyncHelpers.test.ts +112 -0
- package/lib/test-utils/helpers/asyncHelpers.ts +196 -0
- package/lib/test-utils/helpers/index.ts +6 -0
- package/lib/test-utils/helpers.test.ts +73 -0
- package/lib/test-utils/helpers.ts +90 -0
- package/lib/test-utils/index.ts +17 -0
- package/lib/test-utils/mockFactories.ts +92 -0
- package/lib/test-utils/mocks.ts +341 -0
- package/package.json +38 -0
- package/templates/index-router.html +34 -0
- package/tsconfig.json +14 -0
- package/vite.config.ts +43 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { describe, test, expect } from 'bun:test';
|
|
2
|
+
import {
|
|
3
|
+
createValidationError,
|
|
4
|
+
createTypeSafetyError,
|
|
5
|
+
type ValidationError,
|
|
6
|
+
type TypeSafetyError,
|
|
7
|
+
} from './errors';
|
|
8
|
+
|
|
9
|
+
describe('error types', () => {
|
|
10
|
+
describe('createValidationError', () => {
|
|
11
|
+
test('creates error with message only', () => {
|
|
12
|
+
const error = createValidationError('Invalid input');
|
|
13
|
+
expect(error.message).toBe('Invalid input');
|
|
14
|
+
expect(error.path).toBeUndefined();
|
|
15
|
+
expect(error.receivedValue).toBeUndefined();
|
|
16
|
+
expect(error.expectedType).toBeUndefined();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test('creates error with all options', () => {
|
|
20
|
+
const error = createValidationError('Type mismatch', {
|
|
21
|
+
path: 'user.name',
|
|
22
|
+
receivedValue: 123,
|
|
23
|
+
expectedType: 'string',
|
|
24
|
+
});
|
|
25
|
+
expect(error.message).toBe('Type mismatch');
|
|
26
|
+
expect(error.path).toBe('user.name');
|
|
27
|
+
expect(error.receivedValue).toBe(123);
|
|
28
|
+
expect(error.expectedType).toBe('string');
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('creates error with partial options', () => {
|
|
32
|
+
const error = createValidationError('Missing field', {
|
|
33
|
+
path: 'user.email',
|
|
34
|
+
});
|
|
35
|
+
expect(error.message).toBe('Missing field');
|
|
36
|
+
expect(error.path).toBe('user.email');
|
|
37
|
+
expect(error.receivedValue).toBeUndefined();
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe('createTypeSafetyError', () => {
|
|
42
|
+
test('creates error with message only', () => {
|
|
43
|
+
const error = createTypeSafetyError('Type error');
|
|
44
|
+
expect(error).toBeInstanceOf(Error);
|
|
45
|
+
expect(error.message).toBe('Type error');
|
|
46
|
+
expect(error.path).toBeUndefined();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('creates error with all options', () => {
|
|
50
|
+
const error = createTypeSafetyError('Invalid type', {
|
|
51
|
+
path: 'config.value',
|
|
52
|
+
receivedValue: null,
|
|
53
|
+
expectedType: 'number',
|
|
54
|
+
});
|
|
55
|
+
expect(error.message).toBe('Invalid type');
|
|
56
|
+
expect(error.path).toBe('config.value');
|
|
57
|
+
expect(error.receivedValue).toBeNull();
|
|
58
|
+
expect(error.expectedType).toBe('number');
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('error has name property', () => {
|
|
62
|
+
const error = createTypeSafetyError('Test error');
|
|
63
|
+
expect(error.name).toBe('Error');
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test('error has stack trace', () => {
|
|
67
|
+
const error = createTypeSafetyError('Test error');
|
|
68
|
+
expect(error.stack).toBeDefined();
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
describe('ValidationError interface', () => {
|
|
73
|
+
test('supports all properties', () => {
|
|
74
|
+
const error: ValidationError = {
|
|
75
|
+
message: 'Test',
|
|
76
|
+
path: 'test.path',
|
|
77
|
+
receivedValue: 'value',
|
|
78
|
+
expectedType: 'type',
|
|
79
|
+
};
|
|
80
|
+
expect(error.message).toBe('Test');
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('allows optional properties', () => {
|
|
84
|
+
const error: ValidationError = {
|
|
85
|
+
message: 'Test only',
|
|
86
|
+
};
|
|
87
|
+
expect(error.message).toBe('Test only');
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
describe('TypeSafetyError interface', () => {
|
|
92
|
+
test('is an Error instance', () => {
|
|
93
|
+
const error = createTypeSafetyError('Test');
|
|
94
|
+
expect(error).toBeInstanceOf(Error);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test('has readonly properties', () => {
|
|
98
|
+
const error = createTypeSafetyError('Test', { path: 'test' });
|
|
99
|
+
expect(error.path).toBe('test');
|
|
100
|
+
// TypeScript enforces readonly at compile time
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error Types
|
|
3
|
+
* Structured error types for validation and type safety
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Validation error with context
|
|
8
|
+
*/
|
|
9
|
+
export interface ValidationError {
|
|
10
|
+
path?: string;
|
|
11
|
+
message: string;
|
|
12
|
+
receivedValue?: unknown;
|
|
13
|
+
expectedType?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Type safety error
|
|
18
|
+
* Errors from type mismatches or invalid data structures
|
|
19
|
+
*/
|
|
20
|
+
export interface TypeSafetyError extends Error {
|
|
21
|
+
readonly path?: string;
|
|
22
|
+
readonly receivedValue?: unknown;
|
|
23
|
+
readonly expectedType?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Result type for operations that can fail
|
|
28
|
+
* Replaces null returns with explicit success/failure
|
|
29
|
+
*/
|
|
30
|
+
export type Result<T> =
|
|
31
|
+
| { success: true; data: T }
|
|
32
|
+
| { success: false; error: ValidationError };
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Create a validation error
|
|
36
|
+
*/
|
|
37
|
+
export function createValidationError(
|
|
38
|
+
message: string,
|
|
39
|
+
options?: {
|
|
40
|
+
path?: string;
|
|
41
|
+
receivedValue?: unknown;
|
|
42
|
+
expectedType?: string;
|
|
43
|
+
}
|
|
44
|
+
): ValidationError {
|
|
45
|
+
return {
|
|
46
|
+
message,
|
|
47
|
+
...options,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Create a type safety error
|
|
53
|
+
*/
|
|
54
|
+
export function createTypeSafetyError(
|
|
55
|
+
message: string,
|
|
56
|
+
options?: {
|
|
57
|
+
path?: string;
|
|
58
|
+
receivedValue?: unknown;
|
|
59
|
+
expectedType?: string;
|
|
60
|
+
}
|
|
61
|
+
): TypeSafetyError {
|
|
62
|
+
const error = new Error(message) as TypeSafetyError;
|
|
63
|
+
error.path = options?.path;
|
|
64
|
+
error.receivedValue = options?.receivedValue;
|
|
65
|
+
error.expectedType = options?.expectedType;
|
|
66
|
+
return error;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared TypeScript types and interfaces
|
|
3
|
+
* Used by both client and server code
|
|
4
|
+
*
|
|
5
|
+
* This is the main entry point for all shared types.
|
|
6
|
+
* Types are organized into separate files for better maintainability.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// Export all node types
|
|
10
|
+
export type {
|
|
11
|
+
ComponentNode,
|
|
12
|
+
HtmlNode,
|
|
13
|
+
ComponentInstanceNode,
|
|
14
|
+
SlotMarker,
|
|
15
|
+
EmbedNode,
|
|
16
|
+
ObjectLinkNode,
|
|
17
|
+
LocaleListNode,
|
|
18
|
+
} from './nodes';
|
|
19
|
+
|
|
20
|
+
// Export all component types
|
|
21
|
+
export type {
|
|
22
|
+
ComponentDefinition,
|
|
23
|
+
StructuredComponentDefinition,
|
|
24
|
+
PropDefinition,
|
|
25
|
+
JSONPage,
|
|
26
|
+
PageData,
|
|
27
|
+
PageDataWithComponent,
|
|
28
|
+
I18nValue,
|
|
29
|
+
I18nConfig,
|
|
30
|
+
LocaleConfig,
|
|
31
|
+
} from './components';
|
|
32
|
+
|
|
33
|
+
// Export all style types
|
|
34
|
+
export type {
|
|
35
|
+
StyleValue,
|
|
36
|
+
StyleObject,
|
|
37
|
+
ResponsiveStyleObject,
|
|
38
|
+
StyleMapping,
|
|
39
|
+
} from './styles';
|
|
40
|
+
|
|
41
|
+
// Export all API types
|
|
42
|
+
export type {
|
|
43
|
+
HMRMessage,
|
|
44
|
+
PageListResponse,
|
|
45
|
+
RouteHandler,
|
|
46
|
+
PageMetaData,
|
|
47
|
+
PageCmsConfig,
|
|
48
|
+
} from './api';
|
|
49
|
+
|
|
50
|
+
// Export all CMS types
|
|
51
|
+
export type {
|
|
52
|
+
CMSFieldType,
|
|
53
|
+
CMSFieldDefinition,
|
|
54
|
+
CMSSchema,
|
|
55
|
+
CMSItem,
|
|
56
|
+
CMSCollection,
|
|
57
|
+
CMSRouteMatch,
|
|
58
|
+
CMSFilterOperator,
|
|
59
|
+
CMSFilterCondition,
|
|
60
|
+
CMSSortConfig,
|
|
61
|
+
CMSListQuery,
|
|
62
|
+
CMSListProps,
|
|
63
|
+
} from './cms';
|
|
64
|
+
|
|
65
|
+
// Export rendering types
|
|
66
|
+
export type {
|
|
67
|
+
RenderingContext,
|
|
68
|
+
StyleResolutionOptions,
|
|
69
|
+
ComponentRenderOptions,
|
|
70
|
+
StyleMergeOptions,
|
|
71
|
+
TemplateContext,
|
|
72
|
+
} from './rendering';
|
|
73
|
+
|
|
74
|
+
// Export error types
|
|
75
|
+
export type {
|
|
76
|
+
ValidationError,
|
|
77
|
+
TypeSafetyError,
|
|
78
|
+
Result,
|
|
79
|
+
} from './errors';
|
|
80
|
+
|
|
81
|
+
export {
|
|
82
|
+
createValidationError,
|
|
83
|
+
createTypeSafetyError,
|
|
84
|
+
} from './errors';
|
|
85
|
+
|
|
86
|
+
// Export color and theme types
|
|
87
|
+
export type {
|
|
88
|
+
ColorVariables,
|
|
89
|
+
ColorVariableEntry,
|
|
90
|
+
Theme,
|
|
91
|
+
ThemeConfig,
|
|
92
|
+
ThemeEntry,
|
|
93
|
+
} from './colors';
|
|
94
|
+
|
|
95
|
+
// Note: Path types are exported from ../paths/index.ts, not from here
|
|
96
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component Node Types
|
|
3
|
+
* Core types for representing component tree nodes
|
|
4
|
+
*
|
|
5
|
+
* Types are now inferred from Zod schemas in the node type definition files.
|
|
6
|
+
* This file re-exports them for backward compatibility.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// Re-export all node types from the registry
|
|
10
|
+
// These types are inferred from Zod schemas (single source of truth)
|
|
11
|
+
export type {
|
|
12
|
+
HtmlNode,
|
|
13
|
+
ComponentInstanceNode,
|
|
14
|
+
SlotMarker,
|
|
15
|
+
EmbedNode,
|
|
16
|
+
ObjectLinkNode,
|
|
17
|
+
LocaleListNode,
|
|
18
|
+
TextNode,
|
|
19
|
+
ComponentNode,
|
|
20
|
+
} from '../registry/nodeTypes';
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Rendering Types
|
|
3
|
+
* Types used by both SSR and client rendering for consistency
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { ComponentNode, StyleValue } from './nodes';
|
|
7
|
+
import type { ComponentDefinition, StructuredComponentDefinition } from './components';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Rendering context shared between SSR and client
|
|
11
|
+
*/
|
|
12
|
+
export interface RenderingContext {
|
|
13
|
+
viewportWidth: number;
|
|
14
|
+
componentContext?: string | null;
|
|
15
|
+
parentComponentName?: string | null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Style resolution options
|
|
20
|
+
* Unified options for resolving responsive styles
|
|
21
|
+
*/
|
|
22
|
+
export interface StyleResolutionOptions {
|
|
23
|
+
viewportWidth: number;
|
|
24
|
+
breakpoint?: 'base' | 'tablet' | 'mobile';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Component render options
|
|
29
|
+
* Shared options for rendering component instances
|
|
30
|
+
*/
|
|
31
|
+
export interface ComponentRenderOptions {
|
|
32
|
+
node: ComponentNode;
|
|
33
|
+
componentDef: StructuredComponentDefinition;
|
|
34
|
+
props: Record<string, unknown>;
|
|
35
|
+
children?: ComponentNode['children'];
|
|
36
|
+
viewportWidth: number;
|
|
37
|
+
componentContext?: string | null;
|
|
38
|
+
parentComponentName?: string | null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Style merge options
|
|
43
|
+
*/
|
|
44
|
+
export interface StyleMergeOptions {
|
|
45
|
+
base: StyleValue | null | undefined;
|
|
46
|
+
override: StyleValue | null | undefined;
|
|
47
|
+
viewportWidth: number;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Template evaluation context
|
|
52
|
+
* Extensible context object for template processing in processStructure
|
|
53
|
+
*/
|
|
54
|
+
export interface TemplateContext {
|
|
55
|
+
/** Component instance props */
|
|
56
|
+
props: Record<string, unknown>;
|
|
57
|
+
/** Component definition (for variants, defaults) */
|
|
58
|
+
componentDef?: ComponentDefinition | StructuredComponentDefinition;
|
|
59
|
+
/** Future extension points (cms, page, etc.) */
|
|
60
|
+
[namespace: string]: unknown;
|
|
61
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Style-related Types
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export interface StyleMapping {
|
|
6
|
+
_mapping: true;
|
|
7
|
+
prop: string;
|
|
8
|
+
values: Record<string, string | number>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Link mapping for object-link href - maps prop values to link objects
|
|
13
|
+
* When values is omitted, acts as passthrough for link-type props
|
|
14
|
+
*/
|
|
15
|
+
export interface LinkMapping {
|
|
16
|
+
_mapping: true;
|
|
17
|
+
prop: string;
|
|
18
|
+
values?: Record<string, { href: string; target?: string }>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface StyleObject {
|
|
22
|
+
[key: string]: string | number | StyleMapping;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Responsive style object supporting dynamic breakpoints
|
|
27
|
+
* Always includes 'base', plus any breakpoints defined in project.config.json
|
|
28
|
+
*/
|
|
29
|
+
export interface ResponsiveStyleObject {
|
|
30
|
+
base?: StyleObject;
|
|
31
|
+
[breakpointName: string]: StyleObject | undefined;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Style can be either a flat StyleObject (legacy) or ResponsiveStyleObject (new format)
|
|
36
|
+
*/
|
|
37
|
+
export type StyleValue = StyleObject | ResponsiveStyleObject;
|
|
38
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared TypeScript types and interfaces
|
|
3
|
+
* Used by both client and server code
|
|
4
|
+
*
|
|
5
|
+
* This file maintains backward compatibility while using the new modular type system.
|
|
6
|
+
* All types are re-exported from the organized type modules.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// Re-export all types from the new modular structure
|
|
10
|
+
export * from './types/index';
|
|
11
|
+
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized configuration for utility class mappings
|
|
3
|
+
* Single source of truth for property-to-prefix and CSS generation
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Mapping of CSS properties to utility class prefixes
|
|
7
|
+
export const propertyMap: Record<string, string> = {
|
|
8
|
+
// Padding
|
|
9
|
+
padding: 'p',
|
|
10
|
+
paddingTop: 'pt',
|
|
11
|
+
paddingRight: 'pr',
|
|
12
|
+
paddingBottom: 'pb',
|
|
13
|
+
paddingLeft: 'pl',
|
|
14
|
+
paddingInline: 'px',
|
|
15
|
+
paddingBlock: 'py',
|
|
16
|
+
|
|
17
|
+
// Margin
|
|
18
|
+
margin: 'm',
|
|
19
|
+
marginTop: 'mt',
|
|
20
|
+
marginRight: 'mr',
|
|
21
|
+
marginBottom: 'mb',
|
|
22
|
+
marginLeft: 'ml',
|
|
23
|
+
marginInline: 'mx',
|
|
24
|
+
marginBlock: 'my',
|
|
25
|
+
|
|
26
|
+
// Display & Layout
|
|
27
|
+
display: 'd',
|
|
28
|
+
flexDirection: 'fd',
|
|
29
|
+
justifyContent: 'jc',
|
|
30
|
+
alignItems: 'ai',
|
|
31
|
+
alignContent: 'ac',
|
|
32
|
+
flex: 'flex',
|
|
33
|
+
flexWrap: 'fw',
|
|
34
|
+
gap: 'g',
|
|
35
|
+
rowGap: 'rg',
|
|
36
|
+
columnGap: 'cg',
|
|
37
|
+
|
|
38
|
+
// Sizing
|
|
39
|
+
width: 'w',
|
|
40
|
+
height: 'h',
|
|
41
|
+
maxWidth: 'mw',
|
|
42
|
+
maxHeight: 'mh',
|
|
43
|
+
minWidth: 'miw',
|
|
44
|
+
minHeight: 'mih',
|
|
45
|
+
|
|
46
|
+
// Colors & Background
|
|
47
|
+
backgroundColor: 'bgc',
|
|
48
|
+
background: 'bg',
|
|
49
|
+
color: 'c',
|
|
50
|
+
|
|
51
|
+
// Borders & Radius
|
|
52
|
+
border: 'b',
|
|
53
|
+
borderRadius: 'br',
|
|
54
|
+
borderTop: 'bt',
|
|
55
|
+
borderRight: 'border-r',
|
|
56
|
+
borderBottom: 'bb',
|
|
57
|
+
borderLeft: 'bl',
|
|
58
|
+
borderTopLeftRadius: 'brtl',
|
|
59
|
+
borderTopRightRadius: 'brtr',
|
|
60
|
+
borderBottomLeftRadius: 'brbl',
|
|
61
|
+
borderBottomRightRadius: 'brbr',
|
|
62
|
+
borderColor: 'bc',
|
|
63
|
+
|
|
64
|
+
// Text
|
|
65
|
+
fontSize: 'fs',
|
|
66
|
+
fontWeight: 'fe',
|
|
67
|
+
fontFamily: 'ff',
|
|
68
|
+
textAlign: 'ta',
|
|
69
|
+
textDecoration: 'td',
|
|
70
|
+
lineHeight: 'lh',
|
|
71
|
+
letterSpacing: 'ls',
|
|
72
|
+
listStyle: 'lst',
|
|
73
|
+
|
|
74
|
+
// Transform & Effects
|
|
75
|
+
opacity: 'o',
|
|
76
|
+
transform: 'tm',
|
|
77
|
+
boxShadow: 'bs',
|
|
78
|
+
textShadow: 'ts',
|
|
79
|
+
filter: 'flt',
|
|
80
|
+
|
|
81
|
+
// Positioning
|
|
82
|
+
position: 'pos',
|
|
83
|
+
top: 'top',
|
|
84
|
+
right: 'r',
|
|
85
|
+
bottom: 'bo',
|
|
86
|
+
left: 'l',
|
|
87
|
+
zIndex: 'z',
|
|
88
|
+
|
|
89
|
+
// Grid Layout
|
|
90
|
+
gridTemplateColumns: 'gtc',
|
|
91
|
+
gridTemplateRows: 'gtr',
|
|
92
|
+
gridGap: 'gg',
|
|
93
|
+
gridAutoFlow: 'gaf',
|
|
94
|
+
gridColumn: 'gc',
|
|
95
|
+
gridRow: 'gr',
|
|
96
|
+
gridAutoRows: 'gar',
|
|
97
|
+
gridAutoColumns: 'gac',
|
|
98
|
+
|
|
99
|
+
// Flexbox extras
|
|
100
|
+
flexGrow: 'fg',
|
|
101
|
+
flexShrink: 'fs',
|
|
102
|
+
flexBasis: 'fb',
|
|
103
|
+
order: 'ord',
|
|
104
|
+
|
|
105
|
+
// Other
|
|
106
|
+
overflow: 'ov',
|
|
107
|
+
overflowX: 'ovx',
|
|
108
|
+
overflowY: 'ovy',
|
|
109
|
+
cursor: 'cu',
|
|
110
|
+
transition: 'tn',
|
|
111
|
+
objectFit: 'objf',
|
|
112
|
+
objectPosition: 'objp',
|
|
113
|
+
boxSizing: 'bs',
|
|
114
|
+
visibility: 'vis',
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// Mapping of prefixes to CSS property names for dynamic rule generation
|
|
118
|
+
export const prefixToCSSProperty: Record<string, string> = {
|
|
119
|
+
// Spacing
|
|
120
|
+
p: 'padding',
|
|
121
|
+
pt: 'padding-top',
|
|
122
|
+
pr: 'padding-right',
|
|
123
|
+
pb: 'padding-bottom',
|
|
124
|
+
pl: 'padding-left',
|
|
125
|
+
px: 'padding',
|
|
126
|
+
py: 'padding',
|
|
127
|
+
m: 'margin',
|
|
128
|
+
mt: 'margin-top',
|
|
129
|
+
mr: 'margin-right',
|
|
130
|
+
mb: 'margin-bottom',
|
|
131
|
+
ml: 'margin-left',
|
|
132
|
+
mx: 'margin',
|
|
133
|
+
my: 'margin',
|
|
134
|
+
g: 'gap',
|
|
135
|
+
rg: 'row-gap',
|
|
136
|
+
cg: 'column-gap',
|
|
137
|
+
|
|
138
|
+
// Sizing
|
|
139
|
+
w: 'width',
|
|
140
|
+
h: 'height',
|
|
141
|
+
mw: 'max-width',
|
|
142
|
+
mh: 'max-height',
|
|
143
|
+
miw: 'min-width',
|
|
144
|
+
mih: 'min-height',
|
|
145
|
+
|
|
146
|
+
// Colors & Background
|
|
147
|
+
bgc: 'background-color',
|
|
148
|
+
bg: 'background',
|
|
149
|
+
c: 'color',
|
|
150
|
+
bc: 'border-color',
|
|
151
|
+
|
|
152
|
+
// Borders
|
|
153
|
+
b: 'border',
|
|
154
|
+
br: 'border-radius',
|
|
155
|
+
brtl: 'border-top-left-radius',
|
|
156
|
+
brtr: 'border-top-right-radius',
|
|
157
|
+
brbl: 'border-bottom-left-radius',
|
|
158
|
+
brbr: 'border-bottom-right-radius',
|
|
159
|
+
bt: 'border-top',
|
|
160
|
+
bb: 'border-bottom',
|
|
161
|
+
bl: 'border-left',
|
|
162
|
+
|
|
163
|
+
// Text
|
|
164
|
+
fs: 'font-size',
|
|
165
|
+
fe: 'font-weight',
|
|
166
|
+
ff: 'font-family',
|
|
167
|
+
ta: 'text-align',
|
|
168
|
+
td: 'text-decoration',
|
|
169
|
+
lh: 'line-height',
|
|
170
|
+
ls: 'letter-spacing',
|
|
171
|
+
lst: 'list-style',
|
|
172
|
+
|
|
173
|
+
// Flexbox
|
|
174
|
+
fd: 'flex-direction',
|
|
175
|
+
jc: 'justify-content',
|
|
176
|
+
ai: 'align-items',
|
|
177
|
+
ac: 'align-content',
|
|
178
|
+
flex: 'flex',
|
|
179
|
+
fw: 'flex-wrap',
|
|
180
|
+
fg: 'flex-grow',
|
|
181
|
+
flsh: 'flex-shrink',
|
|
182
|
+
fb: 'flex-basis',
|
|
183
|
+
ord: 'order',
|
|
184
|
+
|
|
185
|
+
// Grid
|
|
186
|
+
gtc: 'grid-template-columns',
|
|
187
|
+
gtr: 'grid-template-rows',
|
|
188
|
+
gg: 'grid-gap',
|
|
189
|
+
gaf: 'grid-auto-flow',
|
|
190
|
+
gc: 'grid-column',
|
|
191
|
+
gr: 'grid-row',
|
|
192
|
+
gar: 'grid-auto-rows',
|
|
193
|
+
gac: 'grid-auto-columns',
|
|
194
|
+
|
|
195
|
+
// Effects
|
|
196
|
+
o: 'opacity',
|
|
197
|
+
bsh: 'box-shadow',
|
|
198
|
+
ts: 'text-shadow',
|
|
199
|
+
flt: 'filter',
|
|
200
|
+
|
|
201
|
+
// Positioning
|
|
202
|
+
pos: 'position',
|
|
203
|
+
top: 'top',
|
|
204
|
+
r: 'right',
|
|
205
|
+
bo: 'bottom',
|
|
206
|
+
l: 'left',
|
|
207
|
+
z: 'z-index',
|
|
208
|
+
|
|
209
|
+
// Other
|
|
210
|
+
ov: 'overflow',
|
|
211
|
+
ovx: 'overflow-x',
|
|
212
|
+
ovy: 'overflow-y',
|
|
213
|
+
cu: 'cursor',
|
|
214
|
+
tn: 'transition',
|
|
215
|
+
objf: 'object-fit',
|
|
216
|
+
objp: 'object-position',
|
|
217
|
+
bsz: 'box-sizing',
|
|
218
|
+
vis: 'visibility',
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
// Special value mappings for specific properties
|
|
222
|
+
export const specialValueMappings: Record<string, Record<string, string>> = {
|
|
223
|
+
display: {
|
|
224
|
+
flex: 'f',
|
|
225
|
+
grid: 'g',
|
|
226
|
+
block: 'b',
|
|
227
|
+
inline: 'i',
|
|
228
|
+
'inline-block': 'ib',
|
|
229
|
+
none: 'h',
|
|
230
|
+
},
|
|
231
|
+
flexDirection: {
|
|
232
|
+
column: 'fd-col',
|
|
233
|
+
row: 'fd-row',
|
|
234
|
+
},
|
|
235
|
+
justifyContent: {
|
|
236
|
+
center: 'jc-c',
|
|
237
|
+
'flex-start': 'jc-s',
|
|
238
|
+
'flex-end': 'jc-e',
|
|
239
|
+
'space-between': 'jc-b',
|
|
240
|
+
'space-around': 'jc-a',
|
|
241
|
+
'space-evenly': 'jc-e',
|
|
242
|
+
},
|
|
243
|
+
alignItems: {
|
|
244
|
+
center: 'ai-c',
|
|
245
|
+
'flex-start': 'ai-s',
|
|
246
|
+
'flex-end': 'ai-e',
|
|
247
|
+
stretch: 'ai-s',
|
|
248
|
+
baseline: 'ai-b',
|
|
249
|
+
},
|
|
250
|
+
overflow: {
|
|
251
|
+
hidden: 'o-h',
|
|
252
|
+
auto: 'o-a',
|
|
253
|
+
scroll: 'o-s',
|
|
254
|
+
visible: 'o-v',
|
|
255
|
+
},
|
|
256
|
+
cursor: {
|
|
257
|
+
pointer: 'cursor-pointer',
|
|
258
|
+
default: 'cursor-default',
|
|
259
|
+
},
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
// Reverse mapping for class-to-style conversion
|
|
263
|
+
export const classToStyleSpecialCases: Record<string, { prop: string; value: string }> = {
|
|
264
|
+
f: { prop: 'display', value: 'flex' },
|
|
265
|
+
'fd-col': { prop: 'flexDirection', value: 'column' },
|
|
266
|
+
'fd-row': { prop: 'flexDirection', value: 'row' },
|
|
267
|
+
g: { prop: 'display', value: 'grid' },
|
|
268
|
+
b: { prop: 'display', value: 'block' },
|
|
269
|
+
i: { prop: 'display', value: 'inline' },
|
|
270
|
+
ib: { prop: 'display', value: 'inline-block' },
|
|
271
|
+
h: { prop: 'display', value: 'none' },
|
|
272
|
+
'jc-c': { prop: 'justifyContent', value: 'center' },
|
|
273
|
+
'jc-s': { prop: 'justifyContent', value: 'flex-start' },
|
|
274
|
+
'jc-e': { prop: 'justifyContent', value: 'flex-end' },
|
|
275
|
+
'jc-b': { prop: 'justifyContent', value: 'space-between' },
|
|
276
|
+
'jc-a': { prop: 'justifyContent', value: 'space-around' },
|
|
277
|
+
'ai-c': { prop: 'alignItems', value: 'center' },
|
|
278
|
+
'ai-s': { prop: 'alignItems', value: 'flex-start' },
|
|
279
|
+
'ai-e': { prop: 'alignItems', value: 'flex-end' },
|
|
280
|
+
'ai-b': { prop: 'alignItems', value: 'baseline' },
|
|
281
|
+
'o-h': { prop: 'overflow', value: 'hidden' },
|
|
282
|
+
'o-a': { prop: 'overflow', value: 'auto' },
|
|
283
|
+
'o-s': { prop: 'overflow', value: 'scroll' },
|
|
284
|
+
'o-v': { prop: 'overflow', value: 'visible' },
|
|
285
|
+
'cursor-pointer': { prop: 'cursor', value: 'pointer' },
|
|
286
|
+
'cursor-default': { prop: 'cursor', value: 'default' },
|
|
287
|
+
};
|