@nestjs-ssr/react 0.3.14 → 0.3.15
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.
|
@@ -11,6 +11,11 @@ const componentName = window.__COMPONENT_NAME__;
|
|
|
11
11
|
const initialProps = window.__INITIAL_STATE__ || {};
|
|
12
12
|
const renderContext = window.__CONTEXT__ || {};
|
|
13
13
|
|
|
14
|
+
/** Convert kebab-case filename to PascalCase (e.g., "login-page" → "LoginPage") */
|
|
15
|
+
function toPascalCase(str: string): string {
|
|
16
|
+
return str.replace(/(^|-)([a-z])/g, (_, __, c: string) => c.toUpperCase());
|
|
17
|
+
}
|
|
18
|
+
|
|
14
19
|
// Auto-discover root layout using Vite's glob import (must match server-side discovery)
|
|
15
20
|
// @ts-ignore - Vite-specific API
|
|
16
21
|
const layoutModules = import.meta.glob('@/views/layout.tsx', {
|
|
@@ -47,9 +52,7 @@ const componentMap = Object.entries(modules)
|
|
|
47
52
|
const component = module.default;
|
|
48
53
|
const name = component.displayName || component.name;
|
|
49
54
|
const filename = path.split('/').pop()?.replace('.tsx', '');
|
|
50
|
-
const normalizedFilename = filename
|
|
51
|
-
? filename.charAt(0).toUpperCase() + filename.slice(1)
|
|
52
|
-
: undefined;
|
|
55
|
+
const normalizedFilename = filename ? toPascalCase(filename) : undefined;
|
|
53
56
|
|
|
54
57
|
return { path, component, name, filename, normalizedFilename };
|
|
55
58
|
});
|
package/package.json
CHANGED
|
@@ -11,6 +11,11 @@ const componentName = window.__COMPONENT_NAME__;
|
|
|
11
11
|
const initialProps = window.__INITIAL_STATE__ || {};
|
|
12
12
|
const renderContext = window.__CONTEXT__ || {};
|
|
13
13
|
|
|
14
|
+
/** Convert kebab-case filename to PascalCase (e.g., "login-page" → "LoginPage") */
|
|
15
|
+
function toPascalCase(str: string): string {
|
|
16
|
+
return str.replace(/(^|-)([a-z])/g, (_, __, c: string) => c.toUpperCase());
|
|
17
|
+
}
|
|
18
|
+
|
|
14
19
|
// Auto-discover root layout using Vite's glob import (must match server-side discovery)
|
|
15
20
|
// @ts-ignore - Vite-specific API
|
|
16
21
|
const layoutModules = import.meta.glob('@/views/layout.tsx', {
|
|
@@ -47,9 +52,7 @@ const componentMap = Object.entries(modules)
|
|
|
47
52
|
const component = module.default;
|
|
48
53
|
const name = component.displayName || component.name;
|
|
49
54
|
const filename = path.split('/').pop()?.replace('.tsx', '');
|
|
50
|
-
const normalizedFilename = filename
|
|
51
|
-
? filename.charAt(0).toUpperCase() + filename.slice(1)
|
|
52
|
-
: undefined;
|
|
55
|
+
const normalizedFilename = filename ? toPascalCase(filename) : undefined;
|
|
53
56
|
|
|
54
57
|
return { path, component, name, filename, normalizedFilename };
|
|
55
58
|
});
|