@seyuna/postcss 1.0.0-canary.22 → 1.0.0-canary.23
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 +7 -0
- package/dist/config.d.ts +4 -0
- package/dist/config.js +40 -0
- package/dist/plugin.js +3 -3
- package/package.json +1 -1
- package/src/config.ts +45 -0
- package/src/plugin.ts +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [1.0.0-canary.23](https://github.com/seyuna-corp/seyuna-postcss/compare/v1.0.0-canary.22...v1.0.0-canary.23) (2026-01-10)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **esm:** prevent deadlock by making config load async ([e8b2d46](https://github.com/seyuna-corp/seyuna-postcss/commit/e8b2d461080bc773a552fdcf4847ee841708ca64))
|
|
7
|
+
|
|
1
8
|
# [1.0.0-canary.22](https://github.com/seyuna-corp/seyuna-postcss/compare/v1.0.0-canary.21...v1.0.0-canary.22) (2026-01-10)
|
|
2
9
|
|
|
3
10
|
|
package/dist/config.d.ts
CHANGED
|
@@ -4,3 +4,7 @@ export declare function loadConfig(options?: PluginOptions): {
|
|
|
4
4
|
config: SeyunaConfig;
|
|
5
5
|
options: Required<PluginOptions>;
|
|
6
6
|
};
|
|
7
|
+
export declare function loadConfigAsync(options?: PluginOptions): Promise<{
|
|
8
|
+
config: SeyunaConfig;
|
|
9
|
+
options: Required<PluginOptions>;
|
|
10
|
+
}>;
|
package/dist/config.js
CHANGED
|
@@ -45,3 +45,43 @@ export function loadConfig(options = {}) {
|
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
+
export async function loadConfigAsync(options = {}) {
|
|
49
|
+
const mergedOptions = { ...DEFAULT_OPTIONS, ...options };
|
|
50
|
+
if (mergedOptions.config) {
|
|
51
|
+
return { config: mergedOptions.config, options: mergedOptions };
|
|
52
|
+
}
|
|
53
|
+
const configPath = path.resolve(process.cwd(), mergedOptions.configPath);
|
|
54
|
+
// Cache config if it's the same path
|
|
55
|
+
if (cachedConfig && cachedConfigPath === configPath) {
|
|
56
|
+
return { config: cachedConfig, options: mergedOptions };
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
try {
|
|
60
|
+
await fs.promises.access(configPath);
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
if (mergedOptions.strict) {
|
|
64
|
+
throw new Error(`Seyuna config not found at ${configPath}`);
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
config: { ui: { theme: { hues: {}, light: { colors: {} }, dark: { colors: {} } } } },
|
|
68
|
+
options: mergedOptions,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const content = await fs.promises.readFile(configPath, 'utf-8');
|
|
72
|
+
const data = JSON.parse(content);
|
|
73
|
+
cachedConfig = data;
|
|
74
|
+
cachedConfigPath = configPath;
|
|
75
|
+
return { config: data, options: mergedOptions };
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
if (mergedOptions.strict) {
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
81
|
+
console.warn(`[Seyuna PostCSS] Warning: Failed to load config: ${error instanceof Error ? error.message : String(error)}`);
|
|
82
|
+
return {
|
|
83
|
+
config: { ui: { theme: { hues: {}, light: { colors: {} }, dark: { colors: {} } } } },
|
|
84
|
+
options: mergedOptions,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
package/dist/plugin.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { functions } from "./functions/index.js";
|
|
2
2
|
import { atRuleHandlers } from "./at-rules/index.js";
|
|
3
|
-
import {
|
|
3
|
+
import { loadConfigAsync } from "./config.js";
|
|
4
4
|
import { processFunctions } from "./parser.js";
|
|
5
5
|
export const dynamicFunctionsPlugin = (opts = {}) => {
|
|
6
6
|
let context;
|
|
7
7
|
let fnMap;
|
|
8
8
|
return {
|
|
9
9
|
postcssPlugin: "postcss-dynamic-functions",
|
|
10
|
-
Once() {
|
|
11
|
-
const { config, options } =
|
|
10
|
+
async Once() {
|
|
11
|
+
const { config, options } = await loadConfigAsync(opts);
|
|
12
12
|
fnMap = { ...functions, ...opts.functions };
|
|
13
13
|
context = {
|
|
14
14
|
config,
|
package/package.json
CHANGED
package/src/config.ts
CHANGED
|
@@ -57,3 +57,48 @@ export function loadConfig(options: PluginOptions = {}): { config: SeyunaConfig,
|
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
+
|
|
61
|
+
export async function loadConfigAsync(options: PluginOptions = {}): Promise<{ config: SeyunaConfig, options: Required<PluginOptions> }> {
|
|
62
|
+
const mergedOptions = { ...DEFAULT_OPTIONS, ...options };
|
|
63
|
+
|
|
64
|
+
if (mergedOptions.config) {
|
|
65
|
+
return { config: mergedOptions.config, options: mergedOptions };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const configPath = path.resolve(process.cwd(), mergedOptions.configPath);
|
|
69
|
+
|
|
70
|
+
// Cache config if it's the same path
|
|
71
|
+
if (cachedConfig && cachedConfigPath === configPath) {
|
|
72
|
+
return { config: cachedConfig, options: mergedOptions };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
try {
|
|
77
|
+
await fs.promises.access(configPath);
|
|
78
|
+
} catch {
|
|
79
|
+
if (mergedOptions.strict) {
|
|
80
|
+
throw new Error(`Seyuna config not found at ${configPath}`);
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
config: { ui: { theme: { hues: {}, light: { colors: {} }, dark: { colors: {} } } } } as any,
|
|
84
|
+
options: mergedOptions,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const content = await fs.promises.readFile(configPath, 'utf-8');
|
|
89
|
+
const data = JSON.parse(content);
|
|
90
|
+
cachedConfig = data;
|
|
91
|
+
cachedConfigPath = configPath;
|
|
92
|
+
|
|
93
|
+
return { config: data, options: mergedOptions };
|
|
94
|
+
} catch (error) {
|
|
95
|
+
if (mergedOptions.strict) {
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
console.warn(`[Seyuna PostCSS] Warning: Failed to load config: ${error instanceof Error ? error.message : String(error)}`);
|
|
99
|
+
return {
|
|
100
|
+
config: { ui: { theme: { hues: {}, light: { colors: {} }, dark: { colors: {} } } } } as any,
|
|
101
|
+
options: mergedOptions,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
package/src/plugin.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PluginCreator } from "postcss";
|
|
2
2
|
import { functions } from "./functions/index.js";
|
|
3
3
|
import { atRuleHandlers } from "./at-rules/index.js";
|
|
4
|
-
import { loadConfig } from "./config.js";
|
|
4
|
+
import { loadConfig, loadConfigAsync } from "./config.js";
|
|
5
5
|
import { PluginOptions, PluginContext, FunctionMap } from "./types.js";
|
|
6
6
|
import { processFunctions } from "./parser.js";
|
|
7
7
|
|
|
@@ -14,8 +14,8 @@ export const dynamicFunctionsPlugin: PluginCreator<PluginOptions> = (
|
|
|
14
14
|
return {
|
|
15
15
|
postcssPlugin: "postcss-dynamic-functions",
|
|
16
16
|
|
|
17
|
-
Once() {
|
|
18
|
-
const { config, options } =
|
|
17
|
+
async Once() {
|
|
18
|
+
const { config, options } = await loadConfigAsync(opts);
|
|
19
19
|
fnMap = { ...functions, ...opts.functions };
|
|
20
20
|
context = {
|
|
21
21
|
config,
|