@seyuna/postcss 1.0.0-canary.37 → 1.0.0-canary.39
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 +26 -0
- package/README.md +444 -156
- package/dist/at-rules/color-scheme.d.ts +3 -2
- package/dist/at-rules/color-scheme.js +6 -7
- package/dist/at-rules/color.d.ts +5 -4
- package/dist/at-rules/color.js +5 -4
- package/dist/at-rules/config.d.ts +2 -1
- package/dist/at-rules/config.js +44 -13
- package/dist/at-rules/container.d.ts +2 -1
- package/dist/at-rules/container.js +4 -6
- package/dist/at-rules/import.d.ts +3 -2
- package/dist/at-rules/import.js +107 -139
- package/dist/at-rules/index.d.ts +2 -1
- package/dist/at-rules/index.js +3 -4
- package/dist/config.js +70 -28
- package/dist/errors.d.ts +3 -5
- package/dist/errors.js +2 -4
- package/dist/functions/color.d.ts +4 -4
- package/dist/functions/color.js +4 -4
- package/dist/functions/index.js +5 -7
- package/dist/helpers.d.ts +4 -6
- package/dist/helpers.js +26 -22
- package/dist/index.d.ts +8 -1
- package/dist/index.js +1 -0
- package/dist/parser.js +36 -49
- package/dist/plugin.d.ts +3 -1
- package/dist/plugin.js +15 -19
- package/dist/types.d.ts +6 -1
- package/dist/types.js +0 -2
- package/package.json +20 -3
- package/.github/workflows/release.yml +0 -41
- package/.vscode/settings.json +0 -4
- package/dist/functions/theme.d.ts +0 -6
- package/dist/functions/theme.js +0 -17
- package/release.config.mjs +0 -37
- package/src/at-rules/color-scheme.ts +0 -54
- package/src/at-rules/color.ts +0 -33
- package/src/at-rules/config.ts +0 -78
- package/src/at-rules/container.ts +0 -58
- package/src/at-rules/import.ts +0 -196
- package/src/at-rules/index.ts +0 -29
- package/src/config.ts +0 -98
- package/src/errors.ts +0 -27
- package/src/functions/color.ts +0 -123
- package/src/functions/index.ts +0 -22
- package/src/functions/theme.ts +0 -20
- package/src/helpers.ts +0 -75
- package/src/index.ts +0 -10
- package/src/parser.ts +0 -81
- package/src/plugin.ts +0 -58
- package/src/styles/seyuna-global.css +0 -94
- package/src/types.ts +0 -71
- package/tests/plugin.test.ts +0 -244
- package/tsconfig.json +0 -14
package/src/helpers.ts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import Rule from "postcss/lib/rule";
|
|
2
|
-
// import type { ChildNode, Declaration, AtRule } from "postcss";
|
|
3
|
-
import { processFunctions } from "./parser.js";
|
|
4
|
-
import { PluginContext } from './types.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Helper: clone nodes and replace {name} placeholders safely
|
|
8
|
-
* Returns only valid Rules or Declarations (never raw AtRules)
|
|
9
|
-
*/
|
|
10
|
-
export function cloneNodes(
|
|
11
|
-
nodes: any[], // ChildNode[]
|
|
12
|
-
name: string,
|
|
13
|
-
context: PluginContext
|
|
14
|
-
): any[] { // ChildNode[]
|
|
15
|
-
const { functions: fnMap } = context;
|
|
16
|
-
|
|
17
|
-
return nodes.flatMap((node) => {
|
|
18
|
-
const cloned = node.clone();
|
|
19
|
-
|
|
20
|
-
if (cloned.type === "decl") {
|
|
21
|
-
const decl = cloned as any; // Declaration
|
|
22
|
-
let value = decl.value.replace(/\{name\}/g, name);
|
|
23
|
-
|
|
24
|
-
// Process functions using the robust parser
|
|
25
|
-
decl.value = processFunctions(value, fnMap, decl, context);
|
|
26
|
-
|
|
27
|
-
return decl;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (cloned.type === "rule") {
|
|
31
|
-
const rule = cloned as Rule;
|
|
32
|
-
if (!rule.selector) return [];
|
|
33
|
-
|
|
34
|
-
rule.selector = rule.selector.replace(/\{name\}/g, name);
|
|
35
|
-
|
|
36
|
-
// Recursively clone child nodes and only keep valid rules/decls
|
|
37
|
-
rule.nodes = cloneNodes(rule.nodes || [], name, context).filter(
|
|
38
|
-
(n) => n.type === "rule" || n.type === "decl"
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
if (!rule.nodes.length) return [];
|
|
42
|
-
return rule;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Ignore AtRules inside rules — they must be processed first
|
|
46
|
-
return [];
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Generate CSS rules from a list of names
|
|
52
|
-
*/
|
|
53
|
-
export function generateRules(
|
|
54
|
-
names: string[],
|
|
55
|
-
atRule: any, // AtRule
|
|
56
|
-
context: PluginContext
|
|
57
|
-
): Rule[] {
|
|
58
|
-
const nodes = atRule.nodes ?? [];
|
|
59
|
-
const generatedRules: Rule[] = [];
|
|
60
|
-
|
|
61
|
-
for (const name of names) {
|
|
62
|
-
const rule = new Rule({
|
|
63
|
-
selector: `&.${name}`,
|
|
64
|
-
source: atRule.source,
|
|
65
|
-
});
|
|
66
|
-
cloneNodes(nodes, name, context).forEach((n) => {
|
|
67
|
-
if (n.type === "rule" && n.selector && (n as Rule).nodes?.length) rule.append(n);
|
|
68
|
-
if (n.type === "decl") rule.append(n);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
if (rule.nodes.length) generatedRules.push(rule);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return generatedRules;
|
|
75
|
-
}
|
package/src/index.ts
DELETED
package/src/parser.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import valueParser from 'postcss-value-parser';
|
|
2
|
-
// import type { Node } from 'postcss';
|
|
3
|
-
import { PluginContext, FunctionMap } from './types.js';
|
|
4
|
-
import { reportError } from './errors.js';
|
|
5
|
-
|
|
6
|
-
// Re-export FunctionMap for backwards compatibility
|
|
7
|
-
export type { FunctionMap } from './types.js';
|
|
8
|
-
|
|
9
|
-
export function processFunctions(
|
|
10
|
-
value: string,
|
|
11
|
-
fnMap: FunctionMap,
|
|
12
|
-
node: any,
|
|
13
|
-
context: PluginContext
|
|
14
|
-
): string {
|
|
15
|
-
const parsed = valueParser(value);
|
|
16
|
-
|
|
17
|
-
// Helper to process nodes recursively (inner-first)
|
|
18
|
-
function processNode(parsedValue: valueParser.ParsedValue) {
|
|
19
|
-
parsedValue.walk((nodeIter) => {
|
|
20
|
-
// If nested nodes exist (e.g., in a function), process them first
|
|
21
|
-
if (nodeIter.type === 'function' && nodeIter.nodes.length > 0) {
|
|
22
|
-
// Here we recursively process child nodes before handling the current function
|
|
23
|
-
// However, value-parser's walk is already a visitor. To do inner-first,
|
|
24
|
-
// we can either walk in reverse or specifically handle children.
|
|
25
|
-
// A simpler way: since walk visits all, we can check if it's a function
|
|
26
|
-
// and if it's one we handle, we process its arguments.
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
// Actually, a manual walk is safer for inner-first replacement
|
|
31
|
-
function traverse(nodes: valueParser.Node[]) {
|
|
32
|
-
for (const nodeIter of nodes) {
|
|
33
|
-
if (nodeIter.type === 'function') {
|
|
34
|
-
// Process inner functions first
|
|
35
|
-
traverse(nodeIter.nodes);
|
|
36
|
-
|
|
37
|
-
// Now handle this function if it's in our map
|
|
38
|
-
if (fnMap[nodeIter.value]) {
|
|
39
|
-
const handler = fnMap[nodeIter.value];
|
|
40
|
-
const args: string[] = [];
|
|
41
|
-
let currentArg = '';
|
|
42
|
-
|
|
43
|
-
nodeIter.nodes.forEach((argNode) => {
|
|
44
|
-
if (argNode.type === 'div' && argNode.value === ',') {
|
|
45
|
-
args.push(currentArg.trim());
|
|
46
|
-
currentArg = '';
|
|
47
|
-
} else {
|
|
48
|
-
currentArg += valueParser.stringify(argNode);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
if (currentArg) {
|
|
53
|
-
args.push(currentArg.trim());
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const cleanedArgs = args.map(arg => arg.replace(/^['"]|['"]$/g, ''));
|
|
57
|
-
|
|
58
|
-
try {
|
|
59
|
-
const result = handler(context, ...cleanedArgs);
|
|
60
|
-
// Replace function with its result
|
|
61
|
-
(nodeIter as any).type = 'word';
|
|
62
|
-
(nodeIter as any).value = result;
|
|
63
|
-
(nodeIter as any).nodes = []; // Clear children
|
|
64
|
-
} catch (error) {
|
|
65
|
-
reportError(
|
|
66
|
-
`Failed to process function "${nodeIter.value}": ${error instanceof Error ? error.message : String(error)}`,
|
|
67
|
-
node,
|
|
68
|
-
context
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
traverse(parsedValue.nodes);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
processNode(parsed);
|
|
80
|
-
return parsed.toString();
|
|
81
|
-
}
|
package/src/plugin.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
// import type { PluginCreator } from "postcss";
|
|
2
|
-
import { functions } from "./functions/index.js";
|
|
3
|
-
import { atRuleHandlers } from "./at-rules/index.js";
|
|
4
|
-
import { loadConfig, loadConfigAsync } from "./config.js";
|
|
5
|
-
import { PluginOptions, PluginContext, FunctionMap } from "./types.js";
|
|
6
|
-
import { processFunctions } from "./parser.js";
|
|
7
|
-
|
|
8
|
-
export const dynamicFunctionsPlugin: any = (
|
|
9
|
-
opts = {}
|
|
10
|
-
) => {
|
|
11
|
-
let context: PluginContext | undefined;
|
|
12
|
-
let fnMap: FunctionMap | undefined;
|
|
13
|
-
|
|
14
|
-
return {
|
|
15
|
-
postcssPlugin: "postcss-dynamic-functions",
|
|
16
|
-
|
|
17
|
-
async Once() {
|
|
18
|
-
try {
|
|
19
|
-
const { config, options } = await loadConfigAsync(opts);
|
|
20
|
-
fnMap = { ...functions, ...(opts as any).functions };
|
|
21
|
-
context = {
|
|
22
|
-
config,
|
|
23
|
-
options,
|
|
24
|
-
functions: fnMap as FunctionMap,
|
|
25
|
-
result: undefined
|
|
26
|
-
};
|
|
27
|
-
} catch (e) {
|
|
28
|
-
throw e;
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
Declaration(decl: any, { result }: any) {
|
|
33
|
-
if (!context || !fnMap) return;
|
|
34
|
-
|
|
35
|
-
// Update context with the current result object
|
|
36
|
-
context.result = result;
|
|
37
|
-
|
|
38
|
-
const newValue = processFunctions(decl.value, fnMap, decl, context);
|
|
39
|
-
|
|
40
|
-
if (newValue !== decl.value) {
|
|
41
|
-
decl.value = newValue;
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
// Override AtRule handler to ensure ordered execution
|
|
46
|
-
AtRule(atRule: any) {
|
|
47
|
-
if (!context) return;
|
|
48
|
-
// Iterate over handlers in order (array) instead of object spread
|
|
49
|
-
for (const { name, handler } of atRuleHandlers) {
|
|
50
|
-
if (atRule.name === name) {
|
|
51
|
-
handler(atRule, context);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
dynamicFunctionsPlugin.postcss = true;
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
@layer reset, base, components, utilities;
|
|
2
|
-
|
|
3
|
-
@layer reset {
|
|
4
|
-
/*
|
|
5
|
-
Reset all elements to a zeroed baseline to ensure consistency in all browsers.
|
|
6
|
-
*/
|
|
7
|
-
*,
|
|
8
|
-
*::before,
|
|
9
|
-
*::after {
|
|
10
|
-
box-sizing: border-box;
|
|
11
|
-
margin: 0;
|
|
12
|
-
padding: 0;
|
|
13
|
-
line-height: 1.5;
|
|
14
|
-
font-family: inherit;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/*
|
|
18
|
-
Prevent automatic font size adjustments on mobile devices to keep text rendering consistent across platforms.
|
|
19
|
-
*/
|
|
20
|
-
html {
|
|
21
|
-
-moz-text-size-adjust: none; /* Firefox */
|
|
22
|
-
-webkit-text-size-adjust: none; /* Safari / older WebKit browsers */
|
|
23
|
-
text-size-adjust: none; /* Modern spec-compliant browsers */
|
|
24
|
-
color: var(--text);
|
|
25
|
-
background-color: var(--background);
|
|
26
|
-
font-size: max(1rem, 0.833vw);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/*
|
|
30
|
-
Remove default list styling from unordered and ordered lists that
|
|
31
|
-
explicitly use role="list".
|
|
32
|
-
*/
|
|
33
|
-
ul[role="list"],
|
|
34
|
-
ol[role="list"] {
|
|
35
|
-
list-style: none;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/*
|
|
39
|
-
Ensure the body element always fills at least the full height of the viewport
|
|
40
|
-
so short pages don't collapse. Improve text rendering across browsers by
|
|
41
|
-
enabling smoother grayscale antialiasing. Set the body as a container
|
|
42
|
-
(queryable by its inline size) for use with CSS container queries, and
|
|
43
|
-
enable smooth scrolling for anchor links and programmatic scroll actions.
|
|
44
|
-
*/
|
|
45
|
-
body {
|
|
46
|
-
min-height: 100vh;
|
|
47
|
-
-webkit-font-smoothing: antialiased;
|
|
48
|
-
-moz-osx-font-smoothing: grayscale;
|
|
49
|
-
container-type: inline-size;
|
|
50
|
-
scroll-behavior: smooth;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/*
|
|
54
|
-
Improve heading readability by evenly distributing words across lines.
|
|
55
|
-
This prevents awkward line breaks and creates more balanced, aesthetic headings.
|
|
56
|
-
*/
|
|
57
|
-
h1,
|
|
58
|
-
h2,
|
|
59
|
-
h3,
|
|
60
|
-
h4,
|
|
61
|
-
h5,
|
|
62
|
-
h6 {
|
|
63
|
-
text-wrap: balance;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/*
|
|
67
|
-
Reset all link styles to inherit from parent elements.
|
|
68
|
-
This removes default colors, underlines, and visited/hover states.
|
|
69
|
-
*/
|
|
70
|
-
a {
|
|
71
|
-
all: unset;
|
|
72
|
-
color: inherit;
|
|
73
|
-
text-decoration: none;
|
|
74
|
-
cursor: pointer;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/*
|
|
78
|
-
Ensure images and <picture> elements scale within their container,
|
|
79
|
-
preventing overflow and maintaining layout integrity on any screen size.
|
|
80
|
-
*/
|
|
81
|
-
img,
|
|
82
|
-
picture {
|
|
83
|
-
max-width: 100%;
|
|
84
|
-
display: block;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/*
|
|
88
|
-
Add extra scroll margin above and below elements targeted via anchors.
|
|
89
|
-
This prevents the element from hugging the top edge of the viewport when navigated to.
|
|
90
|
-
*/
|
|
91
|
-
:target {
|
|
92
|
-
scroll-margin-block: 1rem;
|
|
93
|
-
}
|
|
94
|
-
}
|
package/src/types.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
// Local type definitions to avoid @seyuna/cli runtime import
|
|
2
|
-
// The @seyuna/cli package imports Deno polyfills that conflict with Vite/Astro
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Represents a color in the Oklch color space.
|
|
6
|
-
*/
|
|
7
|
-
export interface Color {
|
|
8
|
-
lightness: number;
|
|
9
|
-
chroma: number;
|
|
10
|
-
hue: number;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* A set of colors for a specific theme mode.
|
|
15
|
-
*/
|
|
16
|
-
export interface Palette {
|
|
17
|
-
chroma: number;
|
|
18
|
-
lightness: number;
|
|
19
|
-
background: Color;
|
|
20
|
-
text: Color;
|
|
21
|
-
colors: Record<string, Color>;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* The complete theme specification.
|
|
26
|
-
*/
|
|
27
|
-
export interface Theme {
|
|
28
|
-
hues: Record<string, number>;
|
|
29
|
-
colors: Record<string, Color>;
|
|
30
|
-
light: Palette;
|
|
31
|
-
dark: Palette;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Supported color appearance modes.
|
|
36
|
-
*/
|
|
37
|
-
export type Mode = "system" | "light" | "dark";
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* UI Engine Configuration.
|
|
41
|
-
*/
|
|
42
|
-
export interface UI {
|
|
43
|
-
theme: Theme;
|
|
44
|
-
output_dir?: string;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Root configuration structure for a Seyuna project.
|
|
49
|
-
*/
|
|
50
|
-
export interface SeyunaConfig {
|
|
51
|
-
ui?: UI;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Shared types to avoid circular dependencies between config.ts and parser.ts
|
|
55
|
-
|
|
56
|
-
export type FunctionMap = Record<
|
|
57
|
-
string,
|
|
58
|
-
(context: PluginContext, ...args: string[]) => string
|
|
59
|
-
>;
|
|
60
|
-
|
|
61
|
-
export interface PluginOptions {
|
|
62
|
-
config?: SeyunaConfig;
|
|
63
|
-
functions?: FunctionMap;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export interface PluginContext {
|
|
67
|
-
config: SeyunaConfig;
|
|
68
|
-
options: Required<PluginOptions> & { modeAttribute: string };
|
|
69
|
-
functions: FunctionMap;
|
|
70
|
-
result?: any; // PostCSS Result
|
|
71
|
-
}
|
package/tests/plugin.test.ts
DELETED
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import postcss from "postcss";
|
|
3
|
-
import plugin from "../src/index";
|
|
4
|
-
|
|
5
|
-
const mockConfig = {
|
|
6
|
-
ui: {
|
|
7
|
-
theme: {
|
|
8
|
-
hues: {
|
|
9
|
-
primary: "200",
|
|
10
|
-
secondary: "100",
|
|
11
|
-
},
|
|
12
|
-
colors: {
|
|
13
|
-
white: { lightness: 1, chroma: 0, hue: 0 },
|
|
14
|
-
black: { lightness: 0, chroma: 0, hue: 0 },
|
|
15
|
-
},
|
|
16
|
-
light: {
|
|
17
|
-
lightness: 0.66,
|
|
18
|
-
colors: {
|
|
19
|
-
surface: { lightness: 1, chroma: 0, hue: 0 },
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
dark: {
|
|
23
|
-
lightness: 0.66,
|
|
24
|
-
colors: {
|
|
25
|
-
surface: { lightness: 0, chroma: 0, hue: 0 },
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
breakpoints: {
|
|
29
|
-
tablet: "48rem",
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
async function run(input: string, opts: any = {}) {
|
|
36
|
-
const mergedOpts = { config: mockConfig, ...opts };
|
|
37
|
-
return postcss([plugin(mergedOpts)]).process(input, { from: undefined });
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
describe("Seyuna PostCSS Plugin", () => {
|
|
41
|
-
it("processes SeyunaStandardColor() function", async () => {
|
|
42
|
-
const input = ".test { color: SeyunaStandardColor(primary); }";
|
|
43
|
-
const output =
|
|
44
|
-
".test { color: oklch(var(--lightness) var(--chroma) var(--primary-hue) / 1)";
|
|
45
|
-
const result = await run(input);
|
|
46
|
-
expect(result.css).toContain(output);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it("processes SeyunaStandardColor() with alpha", async () => {
|
|
50
|
-
const input = ".test { color: SeyunaStandardColor(primary, 0.5); }";
|
|
51
|
-
const output =
|
|
52
|
-
".test { color: oklch(var(--lightness) var(--chroma) var(--primary-hue) / 0.5)";
|
|
53
|
-
const result = await run(input);
|
|
54
|
-
expect(result.css).toContain(output);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("processes SeyunaAlpha() function with color name", async () => {
|
|
58
|
-
const input = ".test { color: SeyunaAlpha(primary, 0.5); }";
|
|
59
|
-
const output =
|
|
60
|
-
"color: oklch(var(--lightness) var(--chroma) var(--primary-hue) / 0.5)";
|
|
61
|
-
const result = await run(input);
|
|
62
|
-
expect(result.css).toContain(output);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it("processes SeyunaLighten() function with color name", async () => {
|
|
66
|
-
const input = ".test { color: SeyunaLighten(primary, 0.1); }";
|
|
67
|
-
const output =
|
|
68
|
-
"color: oklch(calc(var(--lightness) + 0.1) var(--chroma) var(--primary-hue) / 1)";
|
|
69
|
-
const result = await run(input);
|
|
70
|
-
expect(result.css).toContain(output);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it("processes SeyunaDarken() function with color name", async () => {
|
|
74
|
-
const input = ".test { color: SeyunaDarken(primary, 0.1); }";
|
|
75
|
-
const output =
|
|
76
|
-
"color: oklch(calc(var(--lightness) - 0.1) var(--chroma) var(--primary-hue) / 1)";
|
|
77
|
-
const result = await run(input);
|
|
78
|
-
expect(result.css).toContain(output);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it("processes SeyunaTheme() function", async () => {
|
|
82
|
-
// We pass the config via opts for testing
|
|
83
|
-
const input =
|
|
84
|
-
".test { border-radius: SeyunaTheme(ui.theme.breakpoints.tablet); }";
|
|
85
|
-
const result = await run(input, { config: mockConfig });
|
|
86
|
-
expect(result.css).toContain(".test { border-radius: 48rem");
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it("processes @xs container at-rule", async () => {
|
|
90
|
-
const input = "@xs { .box { color: red; } }";
|
|
91
|
-
const result = await run(input);
|
|
92
|
-
expect(result.css).toContain("@container (min-width: 20rem)");
|
|
93
|
-
expect(result.css).toContain(".box { color: red");
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it("processes @light at-rule", async () => {
|
|
97
|
-
const input = "@light { .test { color: black; } }";
|
|
98
|
-
const result = await run(input);
|
|
99
|
-
expect(result.css).toContain("@media (prefers-color-scheme: light)");
|
|
100
|
-
expect(result.css).toContain('[data-mode="system"] &');
|
|
101
|
-
expect(result.css).toContain('[data-mode="light"] &');
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it("processes SeyunaAlpha() with standard color", async () => {
|
|
105
|
-
const input = ".test { color: SeyunaAlpha(primary, 0.5); }";
|
|
106
|
-
const output =
|
|
107
|
-
"color: oklch(var(--lightness) var(--chroma) var(--primary-hue) / 0.5)";
|
|
108
|
-
const result = await run(input, { config: mockConfig });
|
|
109
|
-
expect(result.css).toContain(output);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it("processes SeyunaAlpha() with fixed color", async () => {
|
|
113
|
-
const input = ".test { color: SeyunaAlpha(surface, 0.5); }";
|
|
114
|
-
const output =
|
|
115
|
-
"color: oklch(var(--surface-lightness) var(--surface-chroma) var(--surface-hue) / 0.5)";
|
|
116
|
-
const result = await run(input, { config: mockConfig });
|
|
117
|
-
expect(result.css).toContain(output);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it("processes SeyunaContrast() with fixed color", async () => {
|
|
121
|
-
const input = ".test { color: SeyunaContrast(surface); }";
|
|
122
|
-
const output =
|
|
123
|
-
"color: oklch(calc((var(--surface-lightness) - 0.6) * -1000) 0 0)";
|
|
124
|
-
const result = await run(input, { config: mockConfig });
|
|
125
|
-
expect(result.css).toContain(output);
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it("processes SeyunaContrast() with standard color", async () => {
|
|
129
|
-
const input = ".test { color: SeyunaContrast(primary); }";
|
|
130
|
-
const output = "color: oklch(calc((var(--lightness) - 0.6) * -1000) 0 0)";
|
|
131
|
-
const result = await run(input, { config: mockConfig });
|
|
132
|
-
expect(result.css).toContain(output);
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
it("processes @seyuna;", async () => {
|
|
136
|
-
const input = "@seyuna;";
|
|
137
|
-
const result = await run(input, { config: mockConfig });
|
|
138
|
-
|
|
139
|
-
// Check for root variables (hues)
|
|
140
|
-
expect(result.css).toContain(":root");
|
|
141
|
-
expect(result.css).toContain("--primary-hue: 200");
|
|
142
|
-
expect(result.css).toContain("--secondary-hue: 100");
|
|
143
|
-
expect(result.css).toContain("--alpha-hue: 15");
|
|
144
|
-
expect(result.css).toContain("--omega-hue: 360");
|
|
145
|
-
|
|
146
|
-
// Check for mode selectors
|
|
147
|
-
expect(result.css).toContain('[data-mode="light"]');
|
|
148
|
-
expect(result.css).toContain('[data-mode="dark"]');
|
|
149
|
-
expect(result.css).toContain("--lightness: 0.66");
|
|
150
|
-
|
|
151
|
-
// Check for system preference media queries
|
|
152
|
-
expect(result.css).toContain("@media (prefers-color-scheme: light)");
|
|
153
|
-
expect(result.css).toContain("@media (prefers-color-scheme: dark)");
|
|
154
|
-
|
|
155
|
-
// Check for base styles (reset)
|
|
156
|
-
expect(result.css).toContain("@layer reset");
|
|
157
|
-
expect(result.css).toContain("-webkit-text-size-adjust: none");
|
|
158
|
-
|
|
159
|
-
// Check for palette colors
|
|
160
|
-
expect(result.css).toContain("--surface-lightness: 1");
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
it('configures via @config "seyuna"', async () => {
|
|
164
|
-
const input = `
|
|
165
|
-
@config "seyuna" {
|
|
166
|
-
--hue-custom: 123;
|
|
167
|
-
--color-brand: 0.5 0.2 100;
|
|
168
|
-
--light-lightness: 0.8;
|
|
169
|
-
}
|
|
170
|
-
@seyuna;
|
|
171
|
-
.test {
|
|
172
|
-
color: SeyunaStandardColor(custom);
|
|
173
|
-
background: SeyunaFixedColor(brand);
|
|
174
|
-
}
|
|
175
|
-
`;
|
|
176
|
-
const result = await postcss([plugin({ config: undefined })]).process(
|
|
177
|
-
input,
|
|
178
|
-
{ from: undefined },
|
|
179
|
-
);
|
|
180
|
-
|
|
181
|
-
expect(result.css).not.toContain("@config");
|
|
182
|
-
expect(result.css).toContain("--custom-hue: 123");
|
|
183
|
-
expect(result.css).toContain(
|
|
184
|
-
"color: oklch(var(--lightness) var(--chroma) var(--custom-hue) / 1)",
|
|
185
|
-
);
|
|
186
|
-
expect(result.css).toContain(
|
|
187
|
-
"background: oklch(var(--brand-lightness) var(--brand-chroma) var(--brand-hue) / 1)",
|
|
188
|
-
);
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
it("overrides fixed colors in mode blocks", async () => {
|
|
192
|
-
const input = `
|
|
193
|
-
@config "seyuna" {
|
|
194
|
-
--color-brand: 0.5 0.2 100;
|
|
195
|
-
--light-color-brand: 1 0 100;
|
|
196
|
-
}
|
|
197
|
-
@seyuna;
|
|
198
|
-
`;
|
|
199
|
-
const result = await postcss([plugin({ config: undefined })]).process(
|
|
200
|
-
input,
|
|
201
|
-
{ from: undefined },
|
|
202
|
-
);
|
|
203
|
-
|
|
204
|
-
// Global :root should have the original
|
|
205
|
-
expect(result.css).toContain(":root");
|
|
206
|
-
expect(result.css).toContain("--brand-lightness: 0.5");
|
|
207
|
-
|
|
208
|
-
// Light mode should have the override
|
|
209
|
-
expect(result.css).toContain('[data-mode="light"]');
|
|
210
|
-
expect(result.css).toContain("--brand-lightness: 1");
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
it("injects the CSS reset via @seyuna;", async () => {
|
|
214
|
-
const input = "@seyuna;";
|
|
215
|
-
const result = await run(input, { config: mockConfig });
|
|
216
|
-
|
|
217
|
-
// Verify layers
|
|
218
|
-
expect(result.css).toContain("@layer reset, base, components, utilities;");
|
|
219
|
-
expect(result.css).toContain("@layer reset {");
|
|
220
|
-
|
|
221
|
-
// Verify key reset properties
|
|
222
|
-
expect(result.css).toContain("box-sizing: border-box;");
|
|
223
|
-
expect(result.css).toContain("-webkit-text-size-adjust: none;");
|
|
224
|
-
expect(result.css).toContain("text-size-adjust: none;");
|
|
225
|
-
expect(result.css).toContain("container-type: inline-size;");
|
|
226
|
-
expect(result.css).toContain("text-wrap: balance;");
|
|
227
|
-
expect(result.css).toContain("all: unset;");
|
|
228
|
-
expect(result.css).toContain("scroll-margin-block: 1rem;");
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
it("uses resilient variables for untyped functions in config-less environments", async () => {
|
|
232
|
-
const input = ".test { color: SeyunaAlpha(unknown, 0.5); }";
|
|
233
|
-
const result = await postcss([plugin({ config: undefined })]).process(
|
|
234
|
-
input,
|
|
235
|
-
{
|
|
236
|
-
from: undefined,
|
|
237
|
-
},
|
|
238
|
-
);
|
|
239
|
-
|
|
240
|
-
expect(result.css).toContain(
|
|
241
|
-
"color: oklch(var(--unknown-lightness, var(--lightness)) var(--unknown-chroma, var(--chroma)) var(--unknown-hue) / 0.5)",
|
|
242
|
-
);
|
|
243
|
-
});
|
|
244
|
-
});
|
package/tsconfig.json
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"module": "NodeNext",
|
|
5
|
-
"lib": ["ES2020"],
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"outDir": "dist",
|
|
8
|
-
"strict": true,
|
|
9
|
-
"moduleResolution": "NodeNext",
|
|
10
|
-
"esModuleInterop": true,
|
|
11
|
-
"skipLibCheck": true
|
|
12
|
-
},
|
|
13
|
-
"include": ["src/**/*.ts"]
|
|
14
|
-
}
|