Skip to content

Commit 2ce8dd9

Browse files
authored
Merge pull request #296 from objectstack-ai/copilot/fix-issue-in-object-ui
2 parents 8b5e099 + 829cb97 commit 2ce8dd9

20 files changed

Lines changed: 72 additions & 18 deletions

File tree

packages/components/vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export default defineConfig({
4646
globals: true,
4747
environment: 'happy-dom',
4848
setupFiles: ['../../vitest.setup.ts'],
49+
passWithNoTests: true,
4950
// Ensure dependencies are resolved properly for tests
5051
deps: {
5152
inline: ['@object-ui/core', '@object-ui/react'],

packages/core/src/registry/Registry.ts

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ export class Registry<T = any> {
7272
register(type: string, component: ComponentRenderer<T>, meta?: ComponentMeta) {
7373
const fullType = meta?.namespace ? `${meta.namespace}:${type}` : type;
7474

75+
// Warn if registering without namespace (deprecated pattern)
76+
if (!meta?.namespace) {
77+
console.warn(
78+
`Registering component "${type}" without a namespace is deprecated. ` +
79+
`Please provide a namespace in the meta parameter.`
80+
);
81+
}
82+
7583
if (this.components.has(fullType)) {
7684
// console.warn(`Component type "${fullType}" is already registered. Overwriting.`);
7785
}
@@ -84,7 +92,9 @@ export class Registry<T = any> {
8492

8593
// Also register without namespace for backward compatibility
8694
// This allows "button" to work even when registered as "ui:button"
87-
if (meta?.namespace && !this.components.has(type)) {
95+
// Note: If multiple namespaced components share the same short name,
96+
// the last registration wins for non-namespaced lookups
97+
if (meta?.namespace) {
8898
this.components.set(type, {
8999
type: fullType, // Keep reference to namespaced type
90100
component,
@@ -113,16 +123,13 @@ export class Registry<T = any> {
113123
* registry.get('button', 'ui') // Tries 'ui:button' first, then 'button'
114124
*/
115125
get(type: string, namespace?: string): ComponentRenderer<T> | undefined {
116-
// Try namespaced lookup first if namespace provided
126+
// If namespace is explicitly provided, ONLY look in that namespace (no fallback)
117127
if (namespace) {
118128
const namespacedType = `${namespace}:${type}`;
119-
const namespacedComponent = this.components.get(namespacedType);
120-
if (namespacedComponent) {
121-
return namespacedComponent.component;
122-
}
129+
return this.components.get(namespacedType)?.component;
123130
}
124131

125-
// Fallback to direct type lookup
132+
// When no namespace provided, use backward compatibility lookup
126133
return this.components.get(type)?.component;
127134
}
128135

@@ -134,16 +141,13 @@ export class Registry<T = any> {
134141
* @returns Component configuration or undefined
135142
*/
136143
getConfig(type: string, namespace?: string): ComponentConfig<T> | undefined {
137-
// Try namespaced lookup first if namespace provided
144+
// If namespace is explicitly provided, ONLY look in that namespace (no fallback)
138145
if (namespace) {
139146
const namespacedType = `${namespace}:${type}`;
140-
const namespacedConfig = this.components.get(namespacedType);
141-
if (namespacedConfig) {
142-
return namespacedConfig;
143-
}
147+
return this.components.get(namespacedType);
144148
}
145149

146-
// Fallback to direct type lookup
150+
// When no namespace provided, use backward compatibility lookup
147151
return this.components.get(type);
148152
}
149153

@@ -155,12 +159,12 @@ export class Registry<T = any> {
155159
* @returns True if component is registered
156160
*/
157161
has(type: string, namespace?: string): boolean {
162+
// If namespace is explicitly provided, ONLY look in that namespace (no fallback)
158163
if (namespace) {
159164
const namespacedType = `${namespace}:${type}`;
160-
if (this.components.has(namespacedType)) {
161-
return true;
162-
}
165+
return this.components.has(namespacedType);
163166
}
167+
// When no namespace provided, use backward compatibility lookup
164168
return this.components.has(type);
165169
}
166170

packages/core/src/registry/__tests__/PluginSystem.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ describe('PluginSystem', () => {
2828
}
2929
};
3030

31-
await pluginSystem.loadPlugin(plugin, registry);
31+
// Use legacy mode (useScope: false) to test direct registry access
32+
await pluginSystem.loadPlugin(plugin, registry, false);
3233

3334
expect(pluginSystem.isLoaded('test-plugin')).toBe(true);
3435
expect(pluginSystem.getLoadedPlugins()).toContain('test-plugin');
@@ -201,7 +202,8 @@ describe('PluginSystem', () => {
201202
register: registerFn
202203
};
203204

204-
await pluginSystem.loadPlugin(plugin, registry);
205+
// Use legacy mode (useScope: false) to verify the raw Registry is passed
206+
await pluginSystem.loadPlugin(plugin, registry, false);
205207

206208
expect(registerFn).toHaveBeenCalledWith(registry);
207209
expect(registerFn).toHaveBeenCalledTimes(1);

packages/fields/vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,6 @@ export default defineConfig({
4545
globals: true,
4646
environment: 'happy-dom',
4747
setupFiles: ['../../vitest.setup.ts'],
48+
passWithNoTests: true,
4849
},
4950
});

packages/layout/vite.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,7 @@ export default defineConfig({
3232
],
3333
},
3434
},
35+
test: {
36+
passWithNoTests: true,
37+
},
3538
});

packages/plugin-aggrid/vite.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,7 @@ export default defineConfig({
4747
},
4848
},
4949
},
50+
test: {
51+
passWithNoTests: true,
52+
},
5053
});

packages/plugin-calendar/vite.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,7 @@ export default defineConfig({
4747
},
4848
},
4949
},
50+
test: {
51+
passWithNoTests: true,
52+
},
5053
});

packages/plugin-charts/vite.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,7 @@ export default defineConfig({
4545
},
4646
},
4747
},
48+
test: {
49+
passWithNoTests: true,
50+
},
4851
});

packages/plugin-chatbot/vite.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,7 @@ export default defineConfig({
4646
},
4747
},
4848
},
49+
test: {
50+
passWithNoTests: true,
51+
},
4952
});

packages/plugin-dashboard/vite.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,7 @@ export default defineConfig({
4141
},
4242
},
4343
},
44+
test: {
45+
passWithNoTests: true,
46+
},
4447
});

0 commit comments

Comments
 (0)