@shohojdhara/atomix 0.3.9 → 0.3.10
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.
- package/CHANGELOG.md +6 -3
- package/dist/index.esm.js +99 -101
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +113 -111
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/theme.js +50 -2
- package/dist/theme.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 0.3.
|
|
3
|
+
## [0.3.10] - 2026-01-06
|
|
4
4
|
|
|
5
|
-
###
|
|
5
|
+
### Fixed
|
|
6
|
+
- Fixed `Module not found: Can't resolve './lib/config/loader'` by bundling `loadAtomixConfig` instead of treating it as external.
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
## [0.3.9] - 2026-01-06
|
|
8
9
|
|
|
10
|
+
### Fixed
|
|
11
|
+
- Fixed `Module not found` error by replacing dynamic `require` with static import in `ThemeProvider`. This resolves build issues in external projects (e.g. Next.js).
|
|
9
12
|
All notable changes to this project will be documented in this file.
|
|
10
13
|
|
|
11
14
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
package/dist/index.esm.js
CHANGED
|
@@ -8,8 +8,6 @@ import { Pause, Play, SkipBack, SkipForward, SpeakerX, SpeakerHigh, Gear, Downlo
|
|
|
8
8
|
|
|
9
9
|
import { createPortal } from "react-dom";
|
|
10
10
|
|
|
11
|
-
import { loadAtomixConfig as loadAtomixConfig$1 } from "./lib/config/loader";
|
|
12
|
-
|
|
13
11
|
/**
|
|
14
12
|
* Default theme colors for components
|
|
15
13
|
*/ const THEME_COLORS = [ "primary", "secondary", "success", "info", "warning", "error", "light", "dark" ], SIZES = [ "sm", "md", "lg" ], CLASS_PREFIX = {
|
|
@@ -20316,6 +20314,103 @@ function generateClassName(block, element, modifiers) {
|
|
|
20316
20314
|
return property => getComponentThemeValue(component, property, variant, size);
|
|
20317
20315
|
}
|
|
20318
20316
|
|
|
20317
|
+
/**
|
|
20318
|
+
* Atomix Config Loader
|
|
20319
|
+
*
|
|
20320
|
+
* Helper functions to load atomix.config.ts from external projects.
|
|
20321
|
+
* Similar to how Tailwind loads tailwind.config.js
|
|
20322
|
+
*/
|
|
20323
|
+
/**
|
|
20324
|
+
* Load Atomix configuration from project root
|
|
20325
|
+
*
|
|
20326
|
+
* Attempts to load atomix.config.ts from the current working directory.
|
|
20327
|
+
* Falls back to default config if file doesn't exist.
|
|
20328
|
+
*
|
|
20329
|
+
* @param options - Loader options
|
|
20330
|
+
* @returns Loaded configuration or default
|
|
20331
|
+
*
|
|
20332
|
+
* @example
|
|
20333
|
+
* ```typescript
|
|
20334
|
+
* import { loadAtomixConfig } from '@shohojdhara/atomix/config';
|
|
20335
|
+
* import { createTheme } from '@shohojdhara/atomix/theme';
|
|
20336
|
+
*
|
|
20337
|
+
* const config = loadAtomixConfig();
|
|
20338
|
+
* const theme = createTheme(config.theme?.tokens || {});
|
|
20339
|
+
* ```
|
|
20340
|
+
*/ function loadAtomixConfig(options = {}) {
|
|
20341
|
+
const {configPath: configPath = "atomix.config.ts", required: required = !1} = options, defaultConfig = {
|
|
20342
|
+
prefix: "atomix",
|
|
20343
|
+
theme: {
|
|
20344
|
+
extend: {}
|
|
20345
|
+
}
|
|
20346
|
+
};
|
|
20347
|
+
// Default config
|
|
20348
|
+
// In browser environments, config loading is not supported
|
|
20349
|
+
if ("undefined" != typeof window) {
|
|
20350
|
+
if (required) throw new Error("loadAtomixConfig: Not available in browser environment. Config loading requires Node.js/SSR environment.");
|
|
20351
|
+
return defaultConfig;
|
|
20352
|
+
}
|
|
20353
|
+
// Try to load config file
|
|
20354
|
+
try {
|
|
20355
|
+
// Use dynamic import for ESM compatibility
|
|
20356
|
+
const configModule = require(configPath), config = configModule.default || configModule;
|
|
20357
|
+
// Validate it's an AtomixConfig
|
|
20358
|
+
if (config && "object" == typeof config) return config;
|
|
20359
|
+
throw new Error("Invalid config format");
|
|
20360
|
+
} catch (error) {
|
|
20361
|
+
if (required) throw new Error(`Failed to load config from ${configPath}: ${error.message}`);
|
|
20362
|
+
// Return default config if not required
|
|
20363
|
+
return defaultConfig;
|
|
20364
|
+
}
|
|
20365
|
+
}
|
|
20366
|
+
|
|
20367
|
+
/**
|
|
20368
|
+
* Resolve config path
|
|
20369
|
+
*
|
|
20370
|
+
* Finds atomix.config.ts in the project, checking common locations.
|
|
20371
|
+
* Returns null in browser environments where file system access is not available.
|
|
20372
|
+
*
|
|
20373
|
+
* This function is designed to work in Node.js environments only.
|
|
20374
|
+
* In browser builds, it will always return null without attempting to access Node.js modules.
|
|
20375
|
+
*
|
|
20376
|
+
* @internal This function uses Node.js modules and should not be called in browser environments.
|
|
20377
|
+
*/ function resolveConfigPath() {
|
|
20378
|
+
// Early return for browser environments - prevents any Node.js module access
|
|
20379
|
+
// This check happens before any require() calls, preventing bundlers from analyzing them
|
|
20380
|
+
if ("undefined" != typeof window || "undefined" == typeof process || !process.cwd) return null;
|
|
20381
|
+
// Only attempt to load Node.js modules in Node.js runtime
|
|
20382
|
+
// Use a lazy-loading pattern that prevents static analysis by bundlers
|
|
20383
|
+
try {
|
|
20384
|
+
// Create a function that only executes in Node.js runtime
|
|
20385
|
+
// Use string-based module names to prevent static analysis by bundlers
|
|
20386
|
+
const modules = (() => {
|
|
20387
|
+
// These requires are only executed at runtime in Node.js environments
|
|
20388
|
+
// They are marked as external in Rollup config and should not be bundled
|
|
20389
|
+
// Using string concatenation and computed property access to prevent static analysis
|
|
20390
|
+
if ("undefined" == typeof require) return null;
|
|
20391
|
+
// Use a try-catch wrapper to safely access require
|
|
20392
|
+
try {
|
|
20393
|
+
// Build module names dynamically to prevent static analysis
|
|
20394
|
+
const moduleNames = [ "fs", "path" ];
|
|
20395
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
|
20396
|
+
return {
|
|
20397
|
+
fs: require(moduleNames[0]),
|
|
20398
|
+
path: require(moduleNames[1])
|
|
20399
|
+
};
|
|
20400
|
+
} catch {
|
|
20401
|
+
return null;
|
|
20402
|
+
}
|
|
20403
|
+
})();
|
|
20404
|
+
if (!modules) return null;
|
|
20405
|
+
const {fs: fs, path: path} = modules, cwd = process.cwd(), possiblePaths = [ path.join(cwd, "atomix.config.ts"), path.join(cwd, "atomix.config.js"), path.join(cwd, "atomix.config.mjs") ];
|
|
20406
|
+
for (const configPath of possiblePaths) if (fs.existsSync(configPath)) return configPath;
|
|
20407
|
+
} catch (error) {
|
|
20408
|
+
// Silently fail in browser environments or when modules are unavailable
|
|
20409
|
+
return null;
|
|
20410
|
+
}
|
|
20411
|
+
return null;
|
|
20412
|
+
}
|
|
20413
|
+
|
|
20319
20414
|
/**
|
|
20320
20415
|
* Theme Configuration Loader
|
|
20321
20416
|
*
|
|
@@ -20333,7 +20428,7 @@ function generateClassName(block, element, modifiers) {
|
|
|
20333
20428
|
// Use static import - the function handles browser environment checks internally
|
|
20334
20429
|
let config;
|
|
20335
20430
|
try {
|
|
20336
|
-
config = loadAtomixConfig
|
|
20431
|
+
config = loadAtomixConfig({
|
|
20337
20432
|
configPath: options?.configPath || "atomix.config.ts",
|
|
20338
20433
|
required: !1 !== options?.required
|
|
20339
20434
|
});
|
|
@@ -20367,7 +20462,7 @@ function generateClassName(block, element, modifiers) {
|
|
|
20367
20462
|
let config;
|
|
20368
20463
|
try {
|
|
20369
20464
|
// loadAtomixConfig is synchronous, not async
|
|
20370
|
-
config = loadAtomixConfig
|
|
20465
|
+
config = loadAtomixConfig({
|
|
20371
20466
|
configPath: options?.configPath || "atomix.config.ts",
|
|
20372
20467
|
required: !1 !== options?.required
|
|
20373
20468
|
});
|
|
@@ -23983,103 +24078,6 @@ function getComponentCSSVars(component) {
|
|
|
23983
24078
|
};
|
|
23984
24079
|
}
|
|
23985
24080
|
|
|
23986
|
-
/**
|
|
23987
|
-
* Atomix Config Loader
|
|
23988
|
-
*
|
|
23989
|
-
* Helper functions to load atomix.config.ts from external projects.
|
|
23990
|
-
* Similar to how Tailwind loads tailwind.config.js
|
|
23991
|
-
*/
|
|
23992
|
-
/**
|
|
23993
|
-
* Load Atomix configuration from project root
|
|
23994
|
-
*
|
|
23995
|
-
* Attempts to load atomix.config.ts from the current working directory.
|
|
23996
|
-
* Falls back to default config if file doesn't exist.
|
|
23997
|
-
*
|
|
23998
|
-
* @param options - Loader options
|
|
23999
|
-
* @returns Loaded configuration or default
|
|
24000
|
-
*
|
|
24001
|
-
* @example
|
|
24002
|
-
* ```typescript
|
|
24003
|
-
* import { loadAtomixConfig } from '@shohojdhara/atomix/config';
|
|
24004
|
-
* import { createTheme } from '@shohojdhara/atomix/theme';
|
|
24005
|
-
*
|
|
24006
|
-
* const config = loadAtomixConfig();
|
|
24007
|
-
* const theme = createTheme(config.theme?.tokens || {});
|
|
24008
|
-
* ```
|
|
24009
|
-
*/ function loadAtomixConfig(options = {}) {
|
|
24010
|
-
const {configPath: configPath = "atomix.config.ts", required: required = !1} = options, defaultConfig = {
|
|
24011
|
-
prefix: "atomix",
|
|
24012
|
-
theme: {
|
|
24013
|
-
extend: {}
|
|
24014
|
-
}
|
|
24015
|
-
};
|
|
24016
|
-
// Default config
|
|
24017
|
-
// In browser environments, config loading is not supported
|
|
24018
|
-
if ("undefined" != typeof window) {
|
|
24019
|
-
if (required) throw new Error("loadAtomixConfig: Not available in browser environment. Config loading requires Node.js/SSR environment.");
|
|
24020
|
-
return defaultConfig;
|
|
24021
|
-
}
|
|
24022
|
-
// Try to load config file
|
|
24023
|
-
try {
|
|
24024
|
-
// Use dynamic import for ESM compatibility
|
|
24025
|
-
const configModule = require(configPath), config = configModule.default || configModule;
|
|
24026
|
-
// Validate it's an AtomixConfig
|
|
24027
|
-
if (config && "object" == typeof config) return config;
|
|
24028
|
-
throw new Error("Invalid config format");
|
|
24029
|
-
} catch (error) {
|
|
24030
|
-
if (required) throw new Error(`Failed to load config from ${configPath}: ${error.message}`);
|
|
24031
|
-
// Return default config if not required
|
|
24032
|
-
return defaultConfig;
|
|
24033
|
-
}
|
|
24034
|
-
}
|
|
24035
|
-
|
|
24036
|
-
/**
|
|
24037
|
-
* Resolve config path
|
|
24038
|
-
*
|
|
24039
|
-
* Finds atomix.config.ts in the project, checking common locations.
|
|
24040
|
-
* Returns null in browser environments where file system access is not available.
|
|
24041
|
-
*
|
|
24042
|
-
* This function is designed to work in Node.js environments only.
|
|
24043
|
-
* In browser builds, it will always return null without attempting to access Node.js modules.
|
|
24044
|
-
*
|
|
24045
|
-
* @internal This function uses Node.js modules and should not be called in browser environments.
|
|
24046
|
-
*/ function resolveConfigPath() {
|
|
24047
|
-
// Early return for browser environments - prevents any Node.js module access
|
|
24048
|
-
// This check happens before any require() calls, preventing bundlers from analyzing them
|
|
24049
|
-
if ("undefined" != typeof window || "undefined" == typeof process || !process.cwd) return null;
|
|
24050
|
-
// Only attempt to load Node.js modules in Node.js runtime
|
|
24051
|
-
// Use a lazy-loading pattern that prevents static analysis by bundlers
|
|
24052
|
-
try {
|
|
24053
|
-
// Create a function that only executes in Node.js runtime
|
|
24054
|
-
// Use string-based module names to prevent static analysis by bundlers
|
|
24055
|
-
const modules = (() => {
|
|
24056
|
-
// These requires are only executed at runtime in Node.js environments
|
|
24057
|
-
// They are marked as external in Rollup config and should not be bundled
|
|
24058
|
-
// Using string concatenation and computed property access to prevent static analysis
|
|
24059
|
-
if ("undefined" == typeof require) return null;
|
|
24060
|
-
// Use a try-catch wrapper to safely access require
|
|
24061
|
-
try {
|
|
24062
|
-
// Build module names dynamically to prevent static analysis
|
|
24063
|
-
const moduleNames = [ "fs", "path" ];
|
|
24064
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
|
24065
|
-
return {
|
|
24066
|
-
fs: require(moduleNames[0]),
|
|
24067
|
-
path: require(moduleNames[1])
|
|
24068
|
-
};
|
|
24069
|
-
} catch {
|
|
24070
|
-
return null;
|
|
24071
|
-
}
|
|
24072
|
-
})();
|
|
24073
|
-
if (!modules) return null;
|
|
24074
|
-
const {fs: fs, path: path} = modules, cwd = process.cwd(), possiblePaths = [ path.join(cwd, "atomix.config.ts"), path.join(cwd, "atomix.config.js"), path.join(cwd, "atomix.config.mjs") ];
|
|
24075
|
-
for (const configPath of possiblePaths) if (fs.existsSync(configPath)) return configPath;
|
|
24076
|
-
} catch (error) {
|
|
24077
|
-
// Silently fail in browser environments or when modules are unavailable
|
|
24078
|
-
return null;
|
|
24079
|
-
}
|
|
24080
|
-
return null;
|
|
24081
|
-
}
|
|
24082
|
-
|
|
24083
24081
|
/**
|
|
24084
24082
|
* Atomix Configuration System
|
|
24085
24083
|
*
|