Skip to content

Commit c764a36

Browse files
Copilothotlong
andcommitted
fix: address code review feedback - split long import, consistent debug check, interpolation warning
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent f30b599 commit c764a36

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

packages/core/src/errors/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ function interpolate(
203203
params: Record<string, string>,
204204
): string {
205205
return template.replace(/\$\{(\w+)\}/g, (_match, key: string) => {
206+
if (!(key in params) && typeof process !== 'undefined' && process.env?.NODE_ENV !== 'production') {
207+
console.warn(`[ObjectUI] Missing interpolation parameter "${key}" in error message template.`);
208+
}
206209
return params[key] ?? `\${${key}}`;
207210
});
208211
}

packages/core/src/utils/debug.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ type DebugCategory = 'schema' | 'registry' | 'expression' | 'action' | 'plugin'
1010

1111
function isDebugEnabled(): boolean {
1212
try {
13+
const g = typeof globalThis !== 'undefined' && (globalThis as any).OBJECTUI_DEBUG;
1314
return (
14-
(typeof globalThis !== 'undefined' && (globalThis as any).OBJECTUI_DEBUG === true) ||
15+
(g === true || g === 'true') ||
1516
(typeof process !== 'undefined' && process.env?.OBJECTUI_DEBUG === 'true')
1617
);
1718
} catch {

packages/react/src/SchemaRenderer.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,17 @@
77
*/
88

99
import React, { forwardRef, useContext, useMemo, Component } from 'react';
10-
import { SchemaNode, ComponentRegistry, ExpressionEvaluator, isObjectUIError, type ObjectUIError, ERROR_CODES, debugLog, debugTime, debugTimeEnd } from '@object-ui/core';
10+
import {
11+
SchemaNode,
12+
ComponentRegistry,
13+
ExpressionEvaluator,
14+
isObjectUIError,
15+
type ObjectUIError,
16+
ERROR_CODES,
17+
debugLog,
18+
debugTime,
19+
debugTimeEnd,
20+
} from '@object-ui/core';
1121
import { SchemaRendererContext } from './context/SchemaRendererContext';
1222
import { resolveI18nLabel } from './utils/i18n';
1323

0 commit comments

Comments
 (0)