hazo_config 1.2.0 → 1.3.1

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.
@@ -48,4 +48,29 @@ alwaysApply: true
48
48
  - When error messages are shown to the user, they should always be logged verbatem in the serverside log file as well
49
49
  - pretty print the json output
50
50
  - don't import the logger in the client side code
51
- - whenever there's any actions on the database, or any API calls, please add details of the payload and update as well as the resulsts in the log file to help debug issues. For API calls, don't save any base64 data as it is too large.
51
+ - whenever there's any actions on the database, or any API calls, please add details of the payload and update as well as the resulsts in the log file to help debug issues. For API calls, don't save any base64 data as it is too large.
52
+
53
+ [For Packages ES Module Exports]
54
+ - When creating npm packages that will be consumed by ES module bundlers (Next.js, Vite, etc.), ALL export statements MUST use explicit file paths with .js extensions
55
+ - Directory imports like `export * from './components'` are INVALID in ES modules and will fail at runtime
56
+ - ALWAYS use explicit paths: `export * from './components/index.js'` instead of `export * from './components'`
57
+ - Even though source files are .ts, TypeScript requires .js extensions in import/export paths for ES module output
58
+ - This applies to all export statements in index.ts files and any barrel export files
59
+
60
+ [For packages: TypeScript Configuration]
61
+ - For package builds (tsconfig.build.json), set moduleResolution to "node16" or "node" (not "bundler") when shipping compiled output
62
+ - Ensure module is set to "ESNext" or "ES2020" for modern ES module output
63
+ - Add "type": "module" to package.json if shipping pure ESM packages
64
+
65
+ [For Packages: Export Path Rules]
66
+ - ✅ CORRECT: `export * from './lib/index.js'`
67
+ - ✅ CORRECT: `export * from './components/index.js'`
68
+ - ✅ CORRECT: `export { Something } from './utils.js'`
69
+ - ❌ WRONG: `export * from './lib'`
70
+ - ❌ WRONG: `export * from './components'`
71
+ - ❌ WRONG: `export { Something } from './utils'` (without extension)
72
+
73
+ [Verification]
74
+ - After building, check dist/index.js and ensure all export paths have .js extensions
75
+ - Test the built package in a consuming Next.js or ES module project to verify imports work
76
+ - If using TypeScript path aliases (@/...), ensure they are resolved to relative paths in the compiled output (not left as aliases)
@@ -0,0 +1,34 @@
1
+ ---
2
+ description: Rules for package/library development to ensure ES module compatibility
3
+ globs:
4
+ - "src/**/*.ts"
5
+ - "src/**/*.tsx"
6
+ - "tsconfig*.json"
7
+ - "package.json"
8
+ alwaysApply: true
9
+ ---
10
+
11
+ [Package Development - ES Module Exports]
12
+ - When creating npm packages that will be consumed by ES module bundlers (Next.js, Vite, etc.), ALL export statements MUST use explicit file paths with .js extensions
13
+ - Directory imports like `export * from './components'` are INVALID in ES modules and will fail at runtime
14
+ - ALWAYS use explicit paths: `export * from './components/index.js'` instead of `export * from './components'`
15
+ - Even though source files are .ts, TypeScript requires .js extensions in import/export paths for ES module output
16
+ - This applies to all export statements in index.ts files and any barrel export files
17
+
18
+ [TypeScript Configuration for Packages]
19
+ - For package builds (tsconfig.build.json), set moduleResolution to "node16" or "node" (not "bundler") when shipping compiled output
20
+ - Ensure module is set to "ESNext" or "ES2020" for modern ES module output
21
+ - Add "type": "module" to package.json if shipping pure ESM packages
22
+
23
+ [Export Path Rules]
24
+ - ✅ CORRECT: `export * from './lib/index.js'`
25
+ - ✅ CORRECT: `export * from './components/index.js'`
26
+ - ✅ CORRECT: `export { Something } from './utils.js'`
27
+ - ❌ WRONG: `export * from './lib'`
28
+ - ❌ WRONG: `export * from './components'`
29
+ - ❌ WRONG: `export { Something } from './utils'` (without extension)
30
+
31
+ [Verification]
32
+ - After building, check dist/index.js and ensure all export paths have .js extensions
33
+ - Test the built package in a consuming Next.js or ES module project to verify imports work
34
+ - If using TypeScript path aliases (@/...), ensure they are resolved to relative paths in the compiled output (not left as aliases)
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { ConfigProvider } from '@/lib/types';
2
+ import type { ConfigProvider } from '../lib/types';
3
3
  /**
4
4
  * Config editor component props
5
5
  */
@@ -1 +1 @@
1
- {"version":3,"file":"config_editor.d.ts","sourceRoot":"","sources":["../../src/components/config_editor.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA8B,MAAM,OAAO,CAAA;AAElD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAGjD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,eAAe,EAAE,cAAc,CAAA;IAC/B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;CACvB;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAmLpD,CAAA"}
1
+ {"version":3,"file":"config_editor.d.ts","sourceRoot":"","sources":["../../src/components/config_editor.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA8B,MAAM,OAAO,CAAA;AAElD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAGlD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,eAAe,EAAE,cAAc,CAAA;IAC/B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;CACvB;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAmLpD,CAAA"}
@@ -1,20 +1,23 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConfigEditor = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
2
5
  // Config editor component for managing configuration
3
6
  // Provides a more advanced interface for editing configuration values
4
- import { useState, useEffect } from 'react';
5
- import { cn } from '@/lib/utils';
6
- import { RefreshCw, Save } from 'lucide-react';
7
+ const react_1 = require("react");
8
+ const utils_1 = require("../lib/utils");
9
+ const lucide_react_1 = require("lucide-react");
7
10
  /**
8
11
  * Config editor component
9
12
  * Provides interface for viewing and editing configuration with refresh and save capabilities
10
13
  * @param props - Component props
11
14
  * @returns React component
12
15
  */
13
- export const ConfigEditor = ({ config_provider, className, on_update, }) => {
14
- const [sections, set_sections] = useState({});
15
- const [selected_section, set_selected_section] = useState(null);
16
- const [new_key, set_new_key] = useState('');
17
- const [new_value, set_new_value] = useState('');
16
+ const ConfigEditor = ({ config_provider, className, on_update, }) => {
17
+ const [sections, set_sections] = (0, react_1.useState)({});
18
+ const [selected_section, set_selected_section] = (0, react_1.useState)(null);
19
+ const [new_key, set_new_key] = (0, react_1.useState)('');
20
+ const [new_value, set_new_value] = (0, react_1.useState)('');
18
21
  /**
19
22
  * Load configuration from provider
20
23
  */
@@ -29,7 +32,7 @@ export const ConfigEditor = ({ config_provider, className, on_update, }) => {
29
32
  set_selected_section(Object.keys(all_sections)[0]);
30
33
  }
31
34
  };
32
- useEffect(() => {
35
+ (0, react_1.useEffect)(() => {
33
36
  load_config();
34
37
  }, [config_provider]);
35
38
  /**
@@ -74,8 +77,9 @@ export const ConfigEditor = ({ config_provider, className, on_update, }) => {
74
77
  load_config();
75
78
  };
76
79
  const current_section_data = selected_section ? sections[selected_section] : null;
77
- return (_jsxs("div", { className: cn('cls_config_editor space-y-4', className), children: [_jsxs("div", { className: "cls_config_editor_header flex items-center justify-between border-b pb-2", children: [_jsx("h2", { className: "text-xl font-semibold", children: "Configuration Editor" }), _jsxs("div", { className: "flex gap-2", children: [_jsxs("button", { onClick: handle_refresh, className: "px-3 py-1 border rounded hover:bg-muted flex items-center gap-2", "aria-label": "Refresh", children: [_jsx(RefreshCw, { size: 16 }), "Refresh"] }), _jsxs("button", { onClick: handle_save, className: "px-3 py-1 bg-primary text-primary-foreground rounded hover:bg-primary/90 flex items-center gap-2", "aria-label": "Save", children: [_jsx(Save, { size: 16 }), "Save"] })] })] }), _jsxs("div", { className: "cls_config_editor_content grid grid-cols-1 md:grid-cols-3 gap-4", children: [_jsxs("div", { className: "cls_config_sections_list border rounded p-4", children: [_jsx("h3", { className: "font-semibold mb-2", children: "Sections" }), _jsx("div", { className: "space-y-1", children: Object.keys(sections).map((section_name) => (_jsx("button", { onClick: () => set_selected_section(section_name), className: cn('w-full text-left px-2 py-1 rounded text-sm', selected_section === section_name
80
+ return ((0, jsx_runtime_1.jsxs)("div", { className: (0, utils_1.cn)('cls_config_editor space-y-4', className), children: [(0, jsx_runtime_1.jsxs)("div", { className: "cls_config_editor_header flex items-center justify-between border-b pb-2", children: [(0, jsx_runtime_1.jsx)("h2", { className: "text-xl font-semibold", children: "Configuration Editor" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex gap-2", children: [(0, jsx_runtime_1.jsxs)("button", { onClick: handle_refresh, className: "px-3 py-1 border rounded hover:bg-muted flex items-center gap-2", "aria-label": "Refresh", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.RefreshCw, { size: 16 }), "Refresh"] }), (0, jsx_runtime_1.jsxs)("button", { onClick: handle_save, className: "px-3 py-1 bg-primary text-primary-foreground rounded hover:bg-primary/90 flex items-center gap-2", "aria-label": "Save", children: [(0, jsx_runtime_1.jsx)(lucide_react_1.Save, { size: 16 }), "Save"] })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "cls_config_editor_content grid grid-cols-1 md:grid-cols-3 gap-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "cls_config_sections_list border rounded p-4", children: [(0, jsx_runtime_1.jsx)("h3", { className: "font-semibold mb-2", children: "Sections" }), (0, jsx_runtime_1.jsx)("div", { className: "space-y-1", children: Object.keys(sections).map((section_name) => ((0, jsx_runtime_1.jsx)("button", { onClick: () => set_selected_section(section_name), className: (0, utils_1.cn)('w-full text-left px-2 py-1 rounded text-sm', selected_section === section_name
78
81
  ? 'bg-primary text-primary-foreground'
79
- : 'hover:bg-muted'), children: section_name }, section_name))) })] }), _jsx("div", { className: "cls_config_section_content md:col-span-2 border rounded p-4", children: selected_section ? (_jsxs(_Fragment, { children: [_jsx("h3", { className: "font-semibold mb-4", children: selected_section }), _jsxs("div", { className: "space-y-3", children: [current_section_data &&
80
- Object.entries(current_section_data).map(([key, value]) => (_jsxs("div", { className: "cls_config_item", children: [_jsx("label", { className: "block text-sm font-medium mb-1", children: key }), _jsx("input", { type: "text", value: value, onChange: (e) => handle_update_value(selected_section, key, e.target.value), className: "w-full px-2 py-1 border rounded" })] }, key))), _jsxs("div", { className: "cls_add_new_key border-t pt-3 mt-3", children: [_jsx("h4", { className: "text-sm font-medium mb-2", children: "Add New Key" }), _jsxs("div", { className: "space-y-2", children: [_jsx("input", { type: "text", placeholder: "Key name", value: new_key, onChange: (e) => set_new_key(e.target.value), className: "w-full px-2 py-1 border rounded text-sm" }), _jsx("input", { type: "text", placeholder: "Value", value: new_value, onChange: (e) => set_new_value(e.target.value), className: "w-full px-2 py-1 border rounded text-sm" }), _jsx("button", { onClick: handle_add_key, className: "px-3 py-1 bg-primary text-primary-foreground rounded hover:bg-primary/90 text-sm", children: "Add Key" })] })] })] })] })) : (_jsx("div", { className: "text-center text-muted-foreground py-8", children: "Select a section to view/edit" })) })] })] }));
82
+ : 'hover:bg-muted'), children: section_name }, section_name))) })] }), (0, jsx_runtime_1.jsx)("div", { className: "cls_config_section_content md:col-span-2 border rounded p-4", children: selected_section ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("h3", { className: "font-semibold mb-4", children: selected_section }), (0, jsx_runtime_1.jsxs)("div", { className: "space-y-3", children: [current_section_data &&
83
+ Object.entries(current_section_data).map(([key, value]) => ((0, jsx_runtime_1.jsxs)("div", { className: "cls_config_item", children: [(0, jsx_runtime_1.jsx)("label", { className: "block text-sm font-medium mb-1", children: key }), (0, jsx_runtime_1.jsx)("input", { type: "text", value: value, onChange: (e) => handle_update_value(selected_section, key, e.target.value), className: "w-full px-2 py-1 border rounded" })] }, key))), (0, jsx_runtime_1.jsxs)("div", { className: "cls_add_new_key border-t pt-3 mt-3", children: [(0, jsx_runtime_1.jsx)("h4", { className: "text-sm font-medium mb-2", children: "Add New Key" }), (0, jsx_runtime_1.jsxs)("div", { className: "space-y-2", children: [(0, jsx_runtime_1.jsx)("input", { type: "text", placeholder: "Key name", value: new_key, onChange: (e) => set_new_key(e.target.value), className: "w-full px-2 py-1 border rounded text-sm" }), (0, jsx_runtime_1.jsx)("input", { type: "text", placeholder: "Value", value: new_value, onChange: (e) => set_new_value(e.target.value), className: "w-full px-2 py-1 border rounded text-sm" }), (0, jsx_runtime_1.jsx)("button", { onClick: handle_add_key, className: "px-3 py-1 bg-primary text-primary-foreground rounded hover:bg-primary/90 text-sm", children: "Add Key" })] })] })] })] })) : ((0, jsx_runtime_1.jsx)("div", { className: "text-center text-muted-foreground py-8", children: "Select a section to view/edit" })) })] })] }));
81
84
  };
85
+ exports.ConfigEditor = ConfigEditor;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { ConfigProvider } from '@/lib/types';
2
+ import type { ConfigProvider } from '../lib/types';
3
3
  /**
4
4
  * Config viewer component props
5
5
  */
@@ -1 +1 @@
1
- {"version":3,"file":"config_viewer.d.ts","sourceRoot":"","sources":["../../src/components/config_viewer.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA8B,MAAM,OAAO,CAAA;AAElD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAGjD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,eAAe,EAAE,cAAc,CAAA;IAC/B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;CACvB;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAwIpD,CAAA"}
1
+ {"version":3,"file":"config_viewer.d.ts","sourceRoot":"","sources":["../../src/components/config_viewer.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA8B,MAAM,OAAO,CAAA;AAElD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAGlD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,eAAe,EAAE,cAAc,CAAA;IAC/B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;CACvB;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAwIpD,CAAA"}
@@ -1,19 +1,22 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConfigViewer = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
2
5
  // Config viewer component for displaying configuration data
3
6
  // Displays configuration sections and values in a readable format
4
- import { useState, useEffect } from 'react';
5
- import { cn } from '@/lib/utils';
6
- import { Pencil, CheckCircle2, XCircle } from 'lucide-react';
7
+ const react_1 = require("react");
8
+ const utils_1 = require("../lib/utils");
9
+ const lucide_react_1 = require("lucide-react");
7
10
  /**
8
11
  * Config viewer component
9
12
  * Displays configuration sections and allows viewing/editing values
10
13
  * @param props - Component props
11
14
  * @returns React component
12
15
  */
13
- export const ConfigViewer = ({ config_provider, className, on_update, }) => {
14
- const [sections, set_sections] = useState({});
15
- const [editing, set_editing] = useState(null);
16
- const [edit_value, set_edit_value] = useState('');
16
+ const ConfigViewer = ({ config_provider, className, on_update, }) => {
17
+ const [sections, set_sections] = (0, react_1.useState)({});
18
+ const [editing, set_editing] = (0, react_1.useState)(null);
19
+ const [edit_value, set_edit_value] = (0, react_1.useState)('');
17
20
  /**
18
21
  * Load configuration from provider
19
22
  */
@@ -36,7 +39,7 @@ export const ConfigViewer = ({ config_provider, className, on_update, }) => {
36
39
  }
37
40
  set_sections(all_sections);
38
41
  };
39
- useEffect(() => {
42
+ (0, react_1.useEffect)(() => {
40
43
  load_config();
41
44
  }, [config_provider]);
42
45
  /**
@@ -69,8 +72,9 @@ export const ConfigViewer = ({ config_provider, className, on_update, }) => {
69
72
  }
70
73
  }
71
74
  };
72
- return (_jsx("div", { className: cn('cls_config_viewer space-y-4', className), children: Object.keys(sections).length === 0 ? (_jsx("div", { className: "p-4 text-center text-muted-foreground", children: "No configuration sections found" })) : (Object.entries(sections).map(([section_name, section_data]) => (_jsxs("div", { className: "cls_config_section border rounded-lg p-4", children: [_jsx("h3", { className: "text-lg font-semibold mb-3", children: section_name }), _jsx("div", { className: "space-y-2", children: Object.entries(section_data).map(([key, value]) => {
75
+ return ((0, jsx_runtime_1.jsx)("div", { className: (0, utils_1.cn)('cls_config_viewer space-y-4', className), children: Object.keys(sections).length === 0 ? ((0, jsx_runtime_1.jsx)("div", { className: "p-4 text-center text-muted-foreground", children: "No configuration sections found" })) : (Object.entries(sections).map(([section_name, section_data]) => ((0, jsx_runtime_1.jsxs)("div", { className: "cls_config_section border rounded-lg p-4", children: [(0, jsx_runtime_1.jsx)("h3", { className: "text-lg font-semibold mb-3", children: section_name }), (0, jsx_runtime_1.jsx)("div", { className: "space-y-2", children: Object.entries(section_data).map(([key, value]) => {
73
76
  const is_editing = editing?.section === section_name && editing?.key === key;
74
- return (_jsx("div", { className: "cls_config_item flex items-center gap-2", children: _jsxs("div", { className: "flex-1", children: [_jsx("div", { className: "text-sm font-medium text-muted-foreground", children: key }), is_editing ? (_jsxs("div", { className: "flex items-center gap-2 mt-1", children: [_jsx("input", { type: "text", value: edit_value, onChange: (e) => set_edit_value(e.target.value), className: "flex-1 px-2 py-1 border rounded text-sm", autoFocus: true }), _jsx("button", { onClick: save_edit, className: "text-green-600 hover:text-green-700", "aria-label": "Save", children: _jsx(CheckCircle2, { size: 20 }) }), _jsx("button", { onClick: cancel_edit, className: "text-red-600 hover:text-red-700", "aria-label": "Cancel", children: _jsx(XCircle, { size: 20 }) })] })) : (_jsxs("div", { className: "flex items-center gap-2 mt-1", children: [_jsx("div", { className: "flex-1 px-2 py-1 bg-muted rounded text-sm", children: value || '(empty)' }), _jsx("button", { onClick: () => start_edit(section_name, key), className: "text-blue-600 hover:text-blue-700", "aria-label": "Edit", children: _jsx(Pencil, { size: 18 }) })] }))] }) }, key));
77
+ return ((0, jsx_runtime_1.jsx)("div", { className: "cls_config_item flex items-center gap-2", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex-1", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-sm font-medium text-muted-foreground", children: key }), is_editing ? ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2 mt-1", children: [(0, jsx_runtime_1.jsx)("input", { type: "text", value: edit_value, onChange: (e) => set_edit_value(e.target.value), className: "flex-1 px-2 py-1 border rounded text-sm", autoFocus: true }), (0, jsx_runtime_1.jsx)("button", { onClick: save_edit, className: "text-green-600 hover:text-green-700", "aria-label": "Save", children: (0, jsx_runtime_1.jsx)(lucide_react_1.CheckCircle2, { size: 20 }) }), (0, jsx_runtime_1.jsx)("button", { onClick: cancel_edit, className: "text-red-600 hover:text-red-700", "aria-label": "Cancel", children: (0, jsx_runtime_1.jsx)(lucide_react_1.XCircle, { size: 20 }) })] })) : ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2 mt-1", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-1 px-2 py-1 bg-muted rounded text-sm", children: value || '(empty)' }), (0, jsx_runtime_1.jsx)("button", { onClick: () => start_edit(section_name, key), className: "text-blue-600 hover:text-blue-700", "aria-label": "Edit", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Pencil, { size: 18 }) })] }))] }) }, key));
75
78
  }) })] }, section_name)))) }));
76
79
  };
80
+ exports.ConfigViewer = ConfigViewer;
@@ -1,10 +1,14 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { cn } from '@/lib/utils';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExampleComponent = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const utils_1 = require("../lib/utils");
3
6
  /**
4
7
  * Example component for demonstrating the component library setup
5
8
  * @param props - Component props
6
9
  * @returns React component
7
10
  */
8
- export const ExampleComponent = ({ title = 'Example Component', className, }) => {
9
- return (_jsxs("div", { className: cn('cls_example_component p-4 border rounded-lg', className), children: [_jsx("h2", { className: "text-xl font-semibold", children: title }), _jsx("p", { className: "text-muted-foreground mt-2", children: "This is an example component for the config management library." })] }));
11
+ const ExampleComponent = ({ title = 'Example Component', className, }) => {
12
+ return ((0, jsx_runtime_1.jsxs)("div", { className: (0, utils_1.cn)('cls_example_component p-4 border rounded-lg', className), children: [(0, jsx_runtime_1.jsx)("h2", { className: "text-xl font-semibold", children: title }), (0, jsx_runtime_1.jsx)("p", { className: "text-muted-foreground mt-2", children: "This is an example component for the config management library." })] }));
10
13
  };
14
+ exports.ExampleComponent = ExampleComponent;
@@ -1,6 +1,6 @@
1
- export { ExampleComponent } from './example_component';
2
- export { ConfigViewer } from './config_viewer';
3
- export { ConfigEditor } from './config_editor';
4
- export type { ConfigViewerProps } from './config_viewer';
5
- export type { ConfigEditorProps } from './config_editor';
1
+ export { ExampleComponent } from './example_component.js';
2
+ export { ConfigViewer } from './config_viewer.js';
3
+ export { ConfigEditor } from './config_editor.js';
4
+ export type { ConfigViewerProps } from './config_viewer.js';
5
+ export type { ConfigEditorProps } from './config_editor.js';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACxD,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA"}
@@ -1,5 +1,11 @@
1
+ "use strict";
1
2
  // Component exports
2
3
  // Export all components from this file for easy importing
3
- export { ExampleComponent } from './example_component';
4
- export { ConfigViewer } from './config_viewer';
5
- export { ConfigEditor } from './config_editor';
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.ConfigEditor = exports.ConfigViewer = exports.ExampleComponent = void 0;
6
+ var example_component_js_1 = require("./example_component.js");
7
+ Object.defineProperty(exports, "ExampleComponent", { enumerable: true, get: function () { return example_component_js_1.ExampleComponent; } });
8
+ var config_viewer_js_1 = require("./config_viewer.js");
9
+ Object.defineProperty(exports, "ConfigViewer", { enumerable: true, get: function () { return config_viewer_js_1.ConfigViewer; } });
10
+ var config_editor_js_1 = require("./config_editor.js");
11
+ Object.defineProperty(exports, "ConfigEditor", { enumerable: true, get: function () { return config_editor_js_1.ConfigEditor; } });
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from './components';
2
- export * from './lib/utils';
3
- export * from './lib';
1
+ export * from './components/index.js';
2
+ export * from './lib/utils.js';
3
+ export * from './lib/index.js';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,OAAO,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,uBAAuB,CAAA;AACrC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA"}
package/dist/index.js CHANGED
@@ -1,5 +1,21 @@
1
+ "use strict";
1
2
  // Main entry point for the component library
2
3
  // Export all components and utilities from this file
3
- export * from './components';
4
- export * from './lib/utils';
5
- export * from './lib';
4
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
+ if (k2 === undefined) k2 = k;
6
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
+ desc = { enumerable: true, get: function() { return m[k]; } };
9
+ }
10
+ Object.defineProperty(o, k2, desc);
11
+ }) : (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ }));
15
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
17
+ };
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ __exportStar(require("./components/index.js"), exports);
20
+ __exportStar(require("./lib/utils.js"), exports);
21
+ __exportStar(require("./lib/index.js"), exports);
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /**
2
3
  * Purpose: Main implementation of HazoConfig
3
4
  *
@@ -6,10 +7,15 @@
6
7
  * in-memory caching, sync operations, and preservation of file formatting.
7
8
  * Zero dependencies - only Node.js built-ins and the 'ini' package.
8
9
  */
9
- import fs from 'fs';
10
- import path from 'path';
11
- import ini from 'ini';
12
- import { ConfigErrorCode as EC } from './types';
10
+ var __importDefault = (this && this.__importDefault) || function (mod) {
11
+ return (mod && mod.__esModule) ? mod : { "default": mod };
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.HazoConfig = void 0;
15
+ const fs_1 = __importDefault(require("fs"));
16
+ const path_1 = __importDefault(require("path"));
17
+ const ini_1 = __importDefault(require("ini"));
18
+ const types_1 = require("./types");
13
19
  /**
14
20
  * No-op logger implementation (default when no logger provided)
15
21
  */
@@ -25,7 +31,7 @@ const no_op_logger = {
25
31
  * Implements ConfigProvider interface for managing INI configuration files.
26
32
  * Provides sync read/write operations with in-memory caching.
27
33
  */
28
- export class HazoConfig {
34
+ class HazoConfig {
29
35
  /**
30
36
  * Constructor
31
37
  * @param options - Configuration options including filePath and optional logger
@@ -50,12 +56,12 @@ export class HazoConfig {
50
56
  writable: true,
51
57
  value: {}
52
58
  });
53
- this.filePath = path.resolve(options.filePath);
59
+ this.filePath = path_1.default.resolve(options.filePath);
54
60
  this.logger = options.logger || no_op_logger;
55
61
  // Validate file exists
56
- if (!fs.existsSync(this.filePath)) {
62
+ if (!fs_1.default.existsSync(this.filePath)) {
57
63
  const error = new Error(`Configuration file not found: ${this.filePath}`);
58
- error.code = EC.FILE_NOT_FOUND;
64
+ error.code = types_1.ConfigErrorCode.FILE_NOT_FOUND;
59
65
  this.logger.error(`[HazoConfig] Configuration file not found: ${this.filePath}`);
60
66
  throw error;
61
67
  }
@@ -99,17 +105,17 @@ export class HazoConfig {
99
105
  save() {
100
106
  try {
101
107
  // Convert config object back to INI format
102
- const iniContent = ini.stringify(this.config, {
108
+ const iniContent = ini_1.default.stringify(this.config, {
103
109
  section: '[',
104
110
  whitespace: true
105
111
  });
106
112
  // Write to file
107
- fs.writeFileSync(this.filePath, iniContent, 'utf-8');
113
+ fs_1.default.writeFileSync(this.filePath, iniContent, 'utf-8');
108
114
  this.logger.info(`[HazoConfig] Configuration saved to: ${this.filePath}`);
109
115
  }
110
116
  catch (error) {
111
117
  const configError = new Error(`Failed to save configuration: ${error.message || String(error)}`);
112
- configError.code = EC.WRITE_ERROR;
118
+ configError.code = types_1.ConfigErrorCode.WRITE_ERROR;
113
119
  configError.originalError = error;
114
120
  this.logger.error(`[HazoConfig] Failed to save configuration: ${this.filePath}`, { error: String(error) });
115
121
  throw configError;
@@ -122,9 +128,9 @@ export class HazoConfig {
122
128
  refresh() {
123
129
  try {
124
130
  // Read file content
125
- const content = fs.readFileSync(this.filePath, 'utf-8');
131
+ const content = fs_1.default.readFileSync(this.filePath, 'utf-8');
126
132
  // Parse INI content
127
- const parsed = ini.parse(content);
133
+ const parsed = ini_1.default.parse(content);
128
134
  // Convert to our internal format (ensure all values are strings)
129
135
  this.config = {};
130
136
  for (const [section, values] of Object.entries(parsed)) {
@@ -143,13 +149,13 @@ export class HazoConfig {
143
149
  // Handle file read errors
144
150
  if (error.code === 'ENOENT') {
145
151
  const configError = new Error(`Configuration file not found: ${this.filePath}`);
146
- configError.code = EC.FILE_NOT_FOUND;
152
+ configError.code = types_1.ConfigErrorCode.FILE_NOT_FOUND;
147
153
  this.logger.error(`[HazoConfig] Configuration file not found: ${this.filePath}`);
148
154
  throw configError;
149
155
  }
150
156
  // Handle parse errors
151
157
  const configError = new Error(`Failed to parse configuration: ${error.message || String(error)}`);
152
- configError.code = EC.PARSE_ERROR;
158
+ configError.code = types_1.ConfigErrorCode.PARSE_ERROR;
153
159
  configError.originalError = error;
154
160
  this.logger.error(`[HazoConfig] Failed to parse configuration: ${this.filePath}`, { error: String(error) });
155
161
  throw configError;
@@ -175,3 +181,4 @@ export class HazoConfig {
175
181
  return result;
176
182
  }
177
183
  }
184
+ exports.HazoConfig = HazoConfig;
@@ -5,8 +5,8 @@
5
5
  * configuration management utility. It serves as the primary entry point
6
6
  * for consumers of the library.
7
7
  */
8
- export { HazoConfig } from './config-loader';
9
- export { MockConfigProvider } from './mock_config_provider';
10
- export { ConfigErrorCode } from './types';
11
- export type { ConfigProvider, HazoConfigOptions, Logger, HazoConfigError } from './types';
8
+ export { HazoConfig } from './config-loader.js';
9
+ export { MockConfigProvider } from './mock_config_provider.js';
10
+ export { ConfigErrorCode } from './types.js';
11
+ export type { ConfigProvider, HazoConfigOptions, Logger, HazoConfigError } from './types.js';
12
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,YAAY,EACV,cAAc,EACd,iBAAiB,EACjB,MAAM,EACN,eAAe,EAChB,MAAM,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,YAAY,EACV,cAAc,EACd,iBAAiB,EACjB,MAAM,EACN,eAAe,EAChB,MAAM,YAAY,CAAA"}
package/dist/lib/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /**
2
3
  * Purpose: Main export for the HazoConfig library.
3
4
  *
@@ -5,6 +6,11 @@
5
6
  * configuration management utility. It serves as the primary entry point
6
7
  * for consumers of the library.
7
8
  */
8
- export { HazoConfig } from './config-loader';
9
- export { MockConfigProvider } from './mock_config_provider';
10
- export { ConfigErrorCode } from './types';
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.ConfigErrorCode = exports.MockConfigProvider = exports.HazoConfig = void 0;
11
+ var config_loader_js_1 = require("./config-loader.js");
12
+ Object.defineProperty(exports, "HazoConfig", { enumerable: true, get: function () { return config_loader_js_1.HazoConfig; } });
13
+ var mock_config_provider_js_1 = require("./mock_config_provider.js");
14
+ Object.defineProperty(exports, "MockConfigProvider", { enumerable: true, get: function () { return mock_config_provider_js_1.MockConfigProvider; } });
15
+ var types_js_1 = require("./types.js");
16
+ Object.defineProperty(exports, "ConfigErrorCode", { enumerable: true, get: function () { return types_js_1.ConfigErrorCode; } });
@@ -1,10 +1,13 @@
1
+ "use strict";
1
2
  // Mock config provider for browser/Storybook testing
2
3
  // Implements ConfigProvider interface using in-memory storage instead of file system
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.MockConfigProvider = void 0;
3
6
  /**
4
7
  * Mock config provider that stores configuration in memory
5
8
  * Useful for testing and Storybook demonstrations where file system is not available
6
9
  */
7
- export class MockConfigProvider {
10
+ class MockConfigProvider {
8
11
  /**
9
12
  * Constructor
10
13
  * @param initial_config - Optional initial configuration data
@@ -85,3 +88,4 @@ export class MockConfigProvider {
85
88
  }
86
89
  }
87
90
  }
91
+ exports.MockConfigProvider = MockConfigProvider;
package/dist/lib/types.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /**
2
3
  * Purpose: Core interfaces and types for the HazoConfig component.
3
4
  *
@@ -6,14 +7,16 @@
6
7
  * ConfigProvider pattern, configuration options, and error types, ensuring
7
8
  * loose coupling and reusability across different projects.
8
9
  */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.ConfigErrorCode = void 0;
9
12
  /**
10
13
  * Error codes for configuration operations
11
14
  */
12
- export var ConfigErrorCode;
15
+ var ConfigErrorCode;
13
16
  (function (ConfigErrorCode) {
14
17
  ConfigErrorCode["FILE_NOT_FOUND"] = "HAZO_CONFIG_FILE_NOT_FOUND";
15
18
  ConfigErrorCode["READ_ERROR"] = "HAZO_CONFIG_READ_ERROR";
16
19
  ConfigErrorCode["WRITE_ERROR"] = "HAZO_CONFIG_WRITE_ERROR";
17
20
  ConfigErrorCode["PARSE_ERROR"] = "HAZO_CONFIG_PARSE_ERROR";
18
21
  ConfigErrorCode["VALIDATION_ERROR"] = "HAZO_CONFIG_VALIDATION_ERROR";
19
- })(ConfigErrorCode || (ConfigErrorCode = {}));
22
+ })(ConfigErrorCode || (exports.ConfigErrorCode = ConfigErrorCode = {}));
package/dist/lib/utils.js CHANGED
@@ -1,12 +1,15 @@
1
+ "use strict";
1
2
  // Utility functions for the component library
2
3
  // Provides class name merging functionality using clsx and tailwind-merge
3
- import { clsx } from "clsx";
4
- import { twMerge } from "tailwind-merge";
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.cn = cn;
6
+ const clsx_1 = require("clsx");
7
+ const tailwind_merge_1 = require("tailwind-merge");
5
8
  /**
6
9
  * Merges class names using clsx and tailwind-merge
7
10
  * @param inputs - Class values to merge
8
11
  * @returns Merged class string
9
12
  */
10
- export function cn(...inputs) {
11
- return twMerge(clsx(inputs));
13
+ function cn(...inputs) {
14
+ return (0, tailwind_merge_1.twMerge)((0, clsx_1.clsx)(inputs));
12
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hazo_config",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
4
4
  "description": "Config wrapper with error handling",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -3,7 +3,7 @@
3
3
 
4
4
  import type { Meta, StoryObj } from '@storybook/react'
5
5
  import { ConfigEditor } from './config_editor'
6
- import { MockConfigProvider } from '@/lib/mock_config_provider'
6
+ import { MockConfigProvider } from '../lib/mock_config_provider'
7
7
 
8
8
  /**
9
9
  * Sample configuration data for testing
@@ -2,8 +2,8 @@
2
2
  // Provides a more advanced interface for editing configuration values
3
3
 
4
4
  import React, { useState, useEffect } from 'react'
5
- import { cn } from '@/lib/utils'
6
- import type { ConfigProvider } from '@/lib/types'
5
+ import { cn } from '../lib/utils'
6
+ import type { ConfigProvider } from '../lib/types'
7
7
  import { RefreshCw, Save } from 'lucide-react'
8
8
 
9
9
  /**
@@ -3,7 +3,7 @@
3
3
 
4
4
  import type { Meta, StoryObj } from '@storybook/react'
5
5
  import { ConfigViewer } from './config_viewer'
6
- import { MockConfigProvider } from '@/lib/mock_config_provider'
6
+ import { MockConfigProvider } from '../lib/mock_config_provider'
7
7
 
8
8
  /**
9
9
  * Sample configuration data for testing
@@ -2,8 +2,8 @@
2
2
  // Displays configuration sections and values in a readable format
3
3
 
4
4
  import React, { useState, useEffect } from 'react'
5
- import { cn } from '@/lib/utils'
6
- import type { ConfigProvider } from '@/lib/types'
5
+ import { cn } from '../lib/utils'
6
+ import type { ConfigProvider } from '../lib/types'
7
7
  import { Pencil, CheckCircle2, XCircle } from 'lucide-react'
8
8
 
9
9
  /**
@@ -2,7 +2,7 @@
2
2
  // This is a placeholder component to demonstrate the setup
3
3
 
4
4
  import React from 'react'
5
- import { cn } from '@/lib/utils'
5
+ import { cn } from '../lib/utils'
6
6
 
7
7
  /**
8
8
  * Example component props interface
@@ -1,9 +1,9 @@
1
1
  // Component exports
2
2
  // Export all components from this file for easy importing
3
3
 
4
- export { ExampleComponent } from './example_component'
5
- export { ConfigViewer } from './config_viewer'
6
- export { ConfigEditor } from './config_editor'
7
- export type { ConfigViewerProps } from './config_viewer'
8
- export type { ConfigEditorProps } from './config_editor'
4
+ export { ExampleComponent } from './example_component.js'
5
+ export { ConfigViewer } from './config_viewer.js'
6
+ export { ConfigEditor } from './config_editor.js'
7
+ export type { ConfigViewerProps } from './config_viewer.js'
8
+ export type { ConfigEditorProps } from './config_editor.js'
9
9
 
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  // Main entry point for the component library
2
2
  // Export all components and utilities from this file
3
3
 
4
- export * from './components'
5
- export * from './lib/utils'
6
- export * from './lib'
4
+ export * from './components/index.js'
5
+ export * from './lib/utils.js'
6
+ export * from './lib/index.js'
7
7
 
package/src/lib/index.ts CHANGED
@@ -6,13 +6,13 @@
6
6
  * for consumers of the library.
7
7
  */
8
8
 
9
- export { HazoConfig } from './config-loader'
10
- export { MockConfigProvider } from './mock_config_provider'
11
- export { ConfigErrorCode } from './types'
9
+ export { HazoConfig } from './config-loader.js'
10
+ export { MockConfigProvider } from './mock_config_provider.js'
11
+ export { ConfigErrorCode } from './types.js'
12
12
  export type {
13
13
  ConfigProvider,
14
14
  HazoConfigOptions,
15
15
  Logger,
16
16
  HazoConfigError
17
- } from './types'
17
+ } from './types.js'
18
18
 
@@ -2,11 +2,13 @@
2
2
  "extends": "./tsconfig.json",
3
3
  "compilerOptions": {
4
4
  "noEmit": false,
5
+ "module": "Node16",
5
6
  "declaration": true,
6
7
  "declarationMap": true,
7
8
  "outDir": "./dist",
8
9
  "rootDir": "./src",
9
- "allowImportingTsExtensions": false
10
+ "allowImportingTsExtensions": false,
11
+ "moduleResolution": "Node16"
10
12
  },
11
13
  "include": ["src"],
12
14
  "exclude": ["**/*.stories.tsx", "**/*.test.tsx", "**/*.test.ts"]