@object-ui/core 3.3.0 → 3.3.2

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.
Files changed (101) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +20 -1
  3. package/dist/actions/ActionRunner.d.ts +9 -0
  4. package/dist/actions/ActionRunner.js +41 -4
  5. package/dist/adapters/ValueDataSource.js +3 -1
  6. package/dist/registry/Registry.d.ts +47 -0
  7. package/dist/registry/Registry.js +92 -0
  8. package/dist/utils/filter-converter.js +25 -5
  9. package/package.json +32 -8
  10. package/.turbo/turbo-build.log +0 -4
  11. package/src/__benchmarks__/core.bench.ts +0 -64
  12. package/src/__tests__/protocols/DndProtocol.test.ts +0 -186
  13. package/src/__tests__/protocols/KeyboardProtocol.test.ts +0 -177
  14. package/src/__tests__/protocols/NotificationProtocol.test.ts +0 -142
  15. package/src/__tests__/protocols/ResponsiveProtocol.test.ts +0 -176
  16. package/src/__tests__/protocols/SharingProtocol.test.ts +0 -188
  17. package/src/actions/ActionEngine.ts +0 -268
  18. package/src/actions/ActionRunner.ts +0 -717
  19. package/src/actions/TransactionManager.ts +0 -521
  20. package/src/actions/UndoManager.ts +0 -215
  21. package/src/actions/__tests__/ActionEngine.test.ts +0 -206
  22. package/src/actions/__tests__/ActionRunner.params.test.ts +0 -134
  23. package/src/actions/__tests__/ActionRunner.test.ts +0 -711
  24. package/src/actions/__tests__/TransactionManager.test.ts +0 -447
  25. package/src/actions/__tests__/UndoManager.test.ts +0 -320
  26. package/src/actions/index.ts +0 -12
  27. package/src/adapters/ApiDataSource.ts +0 -376
  28. package/src/adapters/README.md +0 -180
  29. package/src/adapters/ValueDataSource.ts +0 -459
  30. package/src/adapters/__tests__/ApiDataSource.test.ts +0 -418
  31. package/src/adapters/__tests__/ValueDataSource.test.ts +0 -571
  32. package/src/adapters/__tests__/resolveDataSource.test.ts +0 -144
  33. package/src/adapters/index.ts +0 -15
  34. package/src/adapters/resolveDataSource.ts +0 -79
  35. package/src/builder/__tests__/schema-builder.test.ts +0 -235
  36. package/src/builder/schema-builder.ts +0 -584
  37. package/src/data-scope/DataScopeManager.ts +0 -269
  38. package/src/data-scope/ViewDataProvider.ts +0 -282
  39. package/src/data-scope/__tests__/DataScopeManager.test.ts +0 -211
  40. package/src/data-scope/__tests__/ViewDataProvider.test.ts +0 -270
  41. package/src/data-scope/index.ts +0 -24
  42. package/src/errors/__tests__/errors.test.ts +0 -292
  43. package/src/errors/index.ts +0 -269
  44. package/src/evaluator/ExpressionCache.ts +0 -206
  45. package/src/evaluator/ExpressionContext.ts +0 -118
  46. package/src/evaluator/ExpressionEvaluator.ts +0 -315
  47. package/src/evaluator/FormulaFunctions.ts +0 -398
  48. package/src/evaluator/SafeExpressionParser.ts +0 -893
  49. package/src/evaluator/__tests__/ExpressionCache.test.ts +0 -135
  50. package/src/evaluator/__tests__/ExpressionContext.test.ts +0 -110
  51. package/src/evaluator/__tests__/ExpressionEvaluator.test.ts +0 -558
  52. package/src/evaluator/__tests__/FormulaFunctions.test.ts +0 -447
  53. package/src/evaluator/index.ts +0 -13
  54. package/src/index.ts +0 -38
  55. package/src/protocols/DndProtocol.ts +0 -168
  56. package/src/protocols/KeyboardProtocol.ts +0 -181
  57. package/src/protocols/NotificationProtocol.ts +0 -150
  58. package/src/protocols/ResponsiveProtocol.ts +0 -210
  59. package/src/protocols/SharingProtocol.ts +0 -185
  60. package/src/protocols/index.ts +0 -13
  61. package/src/query/__tests__/query-ast.test.ts +0 -211
  62. package/src/query/__tests__/window-functions.test.ts +0 -275
  63. package/src/query/index.ts +0 -7
  64. package/src/query/query-ast.ts +0 -341
  65. package/src/registry/PluginScopeImpl.ts +0 -259
  66. package/src/registry/PluginSystem.ts +0 -206
  67. package/src/registry/Registry.ts +0 -219
  68. package/src/registry/WidgetRegistry.ts +0 -316
  69. package/src/registry/__tests__/PluginSystem.test.ts +0 -309
  70. package/src/registry/__tests__/Registry.test.ts +0 -293
  71. package/src/registry/__tests__/WidgetRegistry.test.ts +0 -321
  72. package/src/registry/__tests__/plugin-scope-integration.test.ts +0 -283
  73. package/src/theme/ThemeEngine.ts +0 -530
  74. package/src/theme/__tests__/ThemeEngine.test.ts +0 -668
  75. package/src/theme/index.ts +0 -24
  76. package/src/types/index.ts +0 -21
  77. package/src/utils/__tests__/debug-collector.test.ts +0 -102
  78. package/src/utils/__tests__/debug.test.ts +0 -134
  79. package/src/utils/__tests__/expand-fields.test.ts +0 -120
  80. package/src/utils/__tests__/extract-records.test.ts +0 -50
  81. package/src/utils/__tests__/filter-converter.test.ts +0 -118
  82. package/src/utils/__tests__/merge-views-into-objects.test.ts +0 -110
  83. package/src/utils/__tests__/normalize-quick-filter.test.ts +0 -123
  84. package/src/utils/debug-collector.ts +0 -100
  85. package/src/utils/debug.ts +0 -148
  86. package/src/utils/expand-fields.ts +0 -76
  87. package/src/utils/extract-records.ts +0 -33
  88. package/src/utils/filter-converter.ts +0 -133
  89. package/src/utils/merge-views-into-objects.ts +0 -36
  90. package/src/utils/normalize-quick-filter.ts +0 -78
  91. package/src/validation/__tests__/object-validation-engine.test.ts +0 -567
  92. package/src/validation/__tests__/schema-validator.test.ts +0 -118
  93. package/src/validation/__tests__/validation-engine.test.ts +0 -102
  94. package/src/validation/index.ts +0 -10
  95. package/src/validation/schema-validator.ts +0 -344
  96. package/src/validation/validation-engine.ts +0 -528
  97. package/src/validation/validators/index.ts +0 -25
  98. package/src/validation/validators/object-validation-engine.ts +0 -722
  99. package/tsconfig.json +0 -15
  100. package/tsconfig.tsbuildinfo +0 -1
  101. package/vitest.config.ts +0 -2
@@ -1,206 +0,0 @@
1
- /**
2
- * ObjectUI
3
- * Copyright (c) 2024-present ObjectStack Inc.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
-
9
- import type { Registry } from './Registry.js';
10
- import type { PluginScope, PluginScopeConfig, AppMetadataPlugin, AppPluginContext } from '@object-ui/types';
11
- import { PluginScopeImpl } from './PluginScopeImpl.js';
12
-
13
- export interface PluginDefinition {
14
- name: string;
15
- version: string;
16
- dependencies?: string[]; // Dependencies on other plugins
17
- peerDependencies?: string[]; // Peer dependencies
18
- register: (registry: Registry | PluginScope) => void; // Support both legacy and scoped registration
19
- onLoad?: () => void | Promise<void>; // Lifecycle hook: called after registration
20
- onUnload?: () => void | Promise<void>; // Lifecycle hook: called before unload
21
- scopeConfig?: PluginScopeConfig; // Optional scope configuration
22
- }
23
-
24
- export class PluginSystem {
25
- private plugins = new Map<string, PluginDefinition>();
26
- private loaded = new Set<string>();
27
- private scopes = new Map<string, PluginScopeImpl>();
28
-
29
- /**
30
- * Load a plugin into the system with optional scope isolation
31
- * @param plugin The plugin definition to load
32
- * @param registry The component registry to use for registration
33
- * @param useScope Whether to use scoped loading (default: true for better isolation)
34
- * @throws Error if dependencies are missing
35
- */
36
- async loadPlugin(plugin: PluginDefinition, registry: Registry, useScope: boolean = true): Promise<void> {
37
- // Check if already loaded
38
- if (this.loaded.has(plugin.name)) {
39
- console.warn(`Plugin "${plugin.name}" is already loaded. Skipping.`);
40
- return;
41
- }
42
-
43
- // Check dependencies
44
- for (const dep of plugin.dependencies || []) {
45
- if (!this.loaded.has(dep)) {
46
- throw new Error(`Missing dependency: ${dep} required by ${plugin.name}`);
47
- }
48
- }
49
-
50
- try {
51
- if (useScope) {
52
- // Create scoped environment for plugin
53
- const scope = new PluginScopeImpl(
54
- plugin.name,
55
- plugin.version,
56
- registry,
57
- plugin.scopeConfig
58
- );
59
-
60
- // Store scope for cleanup
61
- this.scopes.set(plugin.name, scope);
62
-
63
- // Execute registration with scope
64
- plugin.register(scope);
65
- } else {
66
- // Legacy mode: direct registry access
67
- plugin.register(registry);
68
- }
69
-
70
- // Store plugin definition
71
- this.plugins.set(plugin.name, plugin);
72
-
73
- // Execute lifecycle hook
74
- await plugin.onLoad?.();
75
-
76
- // Mark as loaded
77
- this.loaded.add(plugin.name);
78
- } catch (error) {
79
- // Clean up on failure
80
- this.plugins.delete(plugin.name);
81
- this.scopes.delete(plugin.name);
82
- throw error;
83
- }
84
- }
85
-
86
- /**
87
- * Unload a plugin from the system
88
- * @param name The name of the plugin to unload
89
- * @throws Error if other plugins depend on this plugin
90
- */
91
- async unloadPlugin(name: string): Promise<void> {
92
- const plugin = this.plugins.get(name);
93
- if (!plugin) {
94
- throw new Error(`Plugin "${name}" is not loaded`);
95
- }
96
-
97
- // Check if any loaded plugins depend on this one
98
- for (const [pluginName, pluginDef] of this.plugins.entries()) {
99
- if (this.loaded.has(pluginName) && pluginDef.dependencies?.includes(name)) {
100
- throw new Error(`Cannot unload plugin "${name}" - plugin "${pluginName}" depends on it`);
101
- }
102
- }
103
-
104
- // Execute lifecycle hook
105
- await plugin.onUnload?.();
106
-
107
- // Clean up scope if exists
108
- const scope = this.scopes.get(name);
109
- if (scope) {
110
- scope.cleanup();
111
- this.scopes.delete(name);
112
- }
113
-
114
- // Remove from loaded set
115
- this.loaded.delete(name);
116
- this.plugins.delete(name);
117
- }
118
-
119
- /**
120
- * Get the scope for a loaded plugin
121
- * @param name The name of the plugin
122
- * @returns The plugin scope or undefined
123
- */
124
- getScope(name: string): PluginScope | undefined {
125
- return this.scopes.get(name);
126
- }
127
-
128
- /**
129
- * Check if a plugin is loaded
130
- * @param name The name of the plugin
131
- * @returns true if the plugin is loaded
132
- */
133
- isLoaded(name: string): boolean {
134
- return this.loaded.has(name);
135
- }
136
-
137
- /**
138
- * Get a loaded plugin definition
139
- * @param name The name of the plugin
140
- * @returns The plugin definition or undefined
141
- */
142
- getPlugin(name: string): PluginDefinition | undefined {
143
- return this.plugins.get(name);
144
- }
145
-
146
- /**
147
- * Get all loaded plugin names
148
- * @returns Array of loaded plugin names
149
- */
150
- getLoadedPlugins(): string[] {
151
- return Array.from(this.loaded);
152
- }
153
-
154
- /**
155
- * Get all plugin definitions
156
- * @returns Array of all plugin definitions
157
- */
158
- getAllPlugins(): PluginDefinition[] {
159
- return Array.from(this.plugins.values());
160
- }
161
-
162
- /**
163
- * Install an AppMetadataPlugin at runtime.
164
- *
165
- * Wraps the plugin as a PluginDefinition, calls its `init()` and `start()`
166
- * lifecycle hooks, and loads it into the system.
167
- *
168
- * @param plugin - An AppMetadataPlugin instance
169
- * @param registry - The component registry
170
- * @param ctx - Optional context passed to the plugin's start() hook
171
- */
172
- async install(plugin: AppMetadataPlugin, registry: Registry, ctx?: AppPluginContext): Promise<void> {
173
- if (this.loaded.has(plugin.name)) {
174
- console.warn(`Plugin "${plugin.name}" is already installed. Skipping.`);
175
- return;
176
- }
177
-
178
- await plugin.init();
179
-
180
- const definition: PluginDefinition = {
181
- name: plugin.name,
182
- version: plugin.version,
183
- register: () => {},
184
- onLoad: async () => {
185
- await plugin.start(ctx ?? { logger: console });
186
- },
187
- onUnload: async () => {
188
- await plugin.stop();
189
- },
190
- };
191
-
192
- await this.loadPlugin(definition, registry);
193
- }
194
-
195
- /**
196
- * Uninstall an AppMetadataPlugin at runtime.
197
- *
198
- * Calls the plugin's `stop()` lifecycle hook (via onUnload) and
199
- * removes it from the system.
200
- *
201
- * @param pluginName - Name of the plugin to uninstall
202
- */
203
- async uninstall(pluginName: string): Promise<void> {
204
- await this.unloadPlugin(pluginName);
205
- }
206
- }
@@ -1,219 +0,0 @@
1
- /**
2
- * ObjectUI
3
- * Copyright (c) 2024-present ObjectStack Inc.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
-
9
- import type { SchemaNode } from '../types/index.js';
10
-
11
- export type ComponentRenderer<T = any> = T;
12
-
13
- export type ComponentInput = {
14
- name: string;
15
- type: 'string' | 'number' | 'boolean' | 'enum' | 'array' | 'object' | 'color' | 'date' | 'code' | 'file' | 'slot';
16
- label?: string;
17
- defaultValue?: any;
18
- required?: boolean;
19
- enum?: string[] | { label: string; value: any }[];
20
- description?: string;
21
- advanced?: boolean;
22
- inputType?: string;
23
- };
24
-
25
- export type ComponentMeta = {
26
- label?: string; // Display name in designer
27
- icon?: string; // Icon name or svg string
28
- category?: string; // Grouping category
29
- namespace?: string; // Component namespace (e.g., 'ui', 'plugin-grid', 'field')
30
- /**
31
- * When true, prevents the component from being registered with a non-namespaced fallback.
32
- * Use this when a component should only be accessible via its full namespaced key.
33
- * This avoids conflicts with other components that share the same base name.
34
- *
35
- * @example
36
- * // Register as 'view:form' only, don't overwrite 'form'
37
- * registry.register('form', FormView, { namespace: 'view', skipFallback: true });
38
- */
39
- skipFallback?: boolean;
40
- inputs?: ComponentInput[];
41
- defaultProps?: Record<string, any>; // Default props when dropped
42
- defaultChildren?: SchemaNode[]; // Default children when dropped
43
- examples?: Record<string, any>; // Example configurations
44
- isContainer?: boolean; // Whether the component can have children
45
- resizable?: boolean; // Whether the component can be resized in the designer
46
- resizeConstraints?: {
47
- width?: boolean;
48
- height?: boolean;
49
- minWidth?: number;
50
- maxWidth?: number;
51
- minHeight?: number;
52
- maxHeight?: number;
53
- };
54
- };
55
-
56
- export type ComponentConfig<T = any> = ComponentMeta & {
57
- type: string;
58
- component: ComponentRenderer<T>;
59
- };
60
-
61
- export class Registry<T = any> {
62
- private components = new Map<string, ComponentConfig<T>>();
63
-
64
- /**
65
- * Register a component with optional namespace support.
66
- * If namespace is provided in meta, the component will be registered as "namespace:type".
67
- *
68
- * @param type - Component type identifier
69
- * @param component - Component renderer
70
- * @param meta - Component metadata (including optional namespace)
71
- *
72
- * @example
73
- * // Register with namespace
74
- * registry.register('button', ButtonComponent, { namespace: 'ui' });
75
- * // Accessible as 'ui:button' or 'button' (fallback)
76
- *
77
- * @example
78
- * // Register without namespace (backward compatible)
79
- * registry.register('button', ButtonComponent);
80
- * // Accessible as 'button'
81
- */
82
- register(type: string, component: ComponentRenderer<T>, meta?: ComponentMeta) {
83
- const fullType = meta?.namespace ? `${meta.namespace}:${type}` : type;
84
-
85
- // Warn if registering without namespace (deprecated pattern)
86
- if (!meta?.namespace) {
87
- console.warn(
88
- `Registering component "${type}" without a namespace is deprecated. ` +
89
- `Please provide a namespace in the meta parameter.\n\n` +
90
- ` Migration:\n` +
91
- ` // Before (deprecated):\n` +
92
- ` registry.register('${type}', MyComponent);\n\n` +
93
- ` // After:\n` +
94
- ` registry.register('${type}', MyComponent, { namespace: 'my-plugin' });\n\n` +
95
- ` See: https://github.com/objectstack-ai/objectui/blob/main/MIGRATION_GUIDE.md`
96
- );
97
- }
98
-
99
- if (this.components.has(fullType)) {
100
- // console.warn(`Component type "${fullType}" is already registered. Overwriting.`);
101
- }
102
-
103
- this.components.set(fullType, {
104
- type: fullType,
105
- component,
106
- ...meta
107
- });
108
-
109
- // Also register without namespace for backward compatibility
110
- // This allows "button" to work even when registered as "ui:button"
111
- // Note: If multiple namespaced components share the same short name,
112
- // the last registration wins for non-namespaced lookups
113
- // Skip this if skipFallback is true to avoid overwriting other components
114
- if (meta?.namespace && !meta?.skipFallback) {
115
- this.components.set(type, {
116
- type: fullType, // Keep reference to namespaced type
117
- component,
118
- ...meta
119
- });
120
- }
121
- }
122
-
123
- /**
124
- * Get a component by type. Supports both namespaced and non-namespaced lookups.
125
- *
126
- * @param type - Component type (e.g., 'button' or 'ui:button')
127
- * @param namespace - Optional namespace for lookup priority
128
- * @returns Component renderer or undefined
129
- *
130
- * @example
131
- * // Direct lookup
132
- * registry.get('ui:button') // Gets ui:button
133
- *
134
- * @example
135
- * // Fallback lookup
136
- * registry.get('button') // Gets first registered button
137
- *
138
- * @example
139
- * // Namespaced lookup with priority
140
- * registry.get('button', 'ui') // Tries 'ui:button' first, then 'button'
141
- */
142
- get(type: string, namespace?: string): ComponentRenderer<T> | undefined {
143
- // If namespace is explicitly provided, ONLY look in that namespace (no fallback)
144
- if (namespace) {
145
- const namespacedType = `${namespace}:${type}`;
146
- return this.components.get(namespacedType)?.component;
147
- }
148
-
149
- // When no namespace provided, use backward compatibility lookup
150
- return this.components.get(type)?.component;
151
- }
152
-
153
- /**
154
- * Get component configuration by type with namespace support.
155
- *
156
- * @param type - Component type (e.g., 'button' or 'ui:button')
157
- * @param namespace - Optional namespace for lookup priority
158
- * @returns Component configuration or undefined
159
- */
160
- getConfig(type: string, namespace?: string): ComponentConfig<T> | undefined {
161
- // If namespace is explicitly provided, ONLY look in that namespace (no fallback)
162
- if (namespace) {
163
- const namespacedType = `${namespace}:${type}`;
164
- return this.components.get(namespacedType);
165
- }
166
-
167
- // When no namespace provided, use backward compatibility lookup
168
- return this.components.get(type);
169
- }
170
-
171
- /**
172
- * Check if a component type is registered.
173
- *
174
- * @param type - Component type (e.g., 'button' or 'ui:button')
175
- * @param namespace - Optional namespace for lookup
176
- * @returns True if component is registered
177
- */
178
- has(type: string, namespace?: string): boolean {
179
- // If namespace is explicitly provided, ONLY look in that namespace (no fallback)
180
- if (namespace) {
181
- const namespacedType = `${namespace}:${type}`;
182
- return this.components.has(namespacedType);
183
- }
184
- // When no namespace provided, use backward compatibility lookup
185
- return this.components.has(type);
186
- }
187
-
188
- /**
189
- * Get all registered component types.
190
- *
191
- * @returns Array of all component type identifiers
192
- */
193
- getAllTypes(): string[] {
194
- return Array.from(this.components.keys());
195
- }
196
-
197
- /**
198
- * Get all registered component configurations.
199
- *
200
- * @returns Array of all component configurations
201
- */
202
- getAllConfigs(): ComponentConfig<T>[] {
203
- return Array.from(this.components.values());
204
- }
205
-
206
- /**
207
- * Get all components in a specific namespace.
208
- *
209
- * @param namespace - Namespace to filter by
210
- * @returns Array of component configurations in the namespace
211
- */
212
- getNamespaceComponents(namespace: string): ComponentConfig<T>[] {
213
- return Array.from(this.components.values()).filter(
214
- config => config.namespace === namespace
215
- );
216
- }
217
- }
218
-
219
- export const ComponentRegistry = new Registry<any>();