Skip to content

Commit ef58bfa

Browse files
author
cand
committed
feat: push dist
1 parent a373e95 commit ef58bfa

File tree

4 files changed

+282
-1
lines changed

4 files changed

+282
-1
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*.log
55
*.tgz
66
coverage
7-
dist
87
lib-cov
98
logs
109
node_modules

dist/index.d.mts

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
type ComponentPropertyValue = string | number | boolean | DesignComponent;
2+
type SupportedDesignNodeType = 'GROUP' | 'FRAME' | 'VECTOR' | 'TEXT' | 'INSTANCE';
3+
interface DesignNodeBase {
4+
name: string;
5+
type: SupportedDesignNodeType;
6+
visible: boolean;
7+
}
8+
type DesignNode = GroupNode | FrameNode | VectorNode | TextNode | DesignComponent;
9+
interface TextNode extends DesignNodeBase {
10+
type: 'TEXT';
11+
characters: string;
12+
}
13+
interface ContainerNodeBase extends DesignNodeBase {
14+
children: DesignNode[];
15+
}
16+
interface GroupNode extends ContainerNodeBase {
17+
type: 'GROUP';
18+
}
19+
interface FrameNode extends ContainerNodeBase {
20+
type: 'FRAME';
21+
}
22+
interface Variable {
23+
name: string;
24+
value: string;
25+
}
26+
interface Fill {
27+
color: string | Variable;
28+
}
29+
interface VectorNode extends DesignNodeBase {
30+
type: 'VECTOR';
31+
fills: Fill[];
32+
}
33+
interface DesignComponent<T extends object = Record<string, ComponentPropertyValue>> extends ContainerNodeBase {
34+
type: 'INSTANCE';
35+
properties: T;
36+
mainComponent?: {
37+
id: string;
38+
name: string;
39+
} | null;
40+
}
41+
interface DevComponent<T extends object = Record<string, unknown>> {
42+
name: string;
43+
props: T;
44+
children: (DevComponent | string)[];
45+
}
46+
type SupportedLang = 'text' | 'tsx' | 'jsx' | 'ts' | 'js' | 'vue' | 'html' | 'css' | 'sass' | 'scss' | 'less' | 'stylus' | 'json';
47+
interface TransformBaseParams {
48+
/**
49+
* The user preferences related to code transformation
50+
* @example { useRem: true, rootFontSize: 16 }
51+
*/
52+
options: {
53+
useRem: boolean;
54+
rootFontSize: number;
55+
};
56+
}
57+
interface TransformParams extends TransformBaseParams {
58+
/**
59+
* The generated CSS code
60+
* @example 'background-color: red; color: blue;'
61+
*/
62+
code: string;
63+
/**
64+
* The parsed CSS properties
65+
* @example { 'background-color': 'red', 'color': 'blue' }
66+
*/
67+
style: Record<string, string>;
68+
}
69+
interface TransformVariableParams extends TransformBaseParams {
70+
/**
71+
* The generated CSS variable code
72+
* @example 'var(--color-primary, #6699cc)'
73+
*/
74+
code: string;
75+
/**
76+
* The variable name
77+
* @example 'color-primary'
78+
*/
79+
name: string;
80+
/**
81+
* The variable value
82+
* @example '#6699cc'
83+
*/
84+
value?: string;
85+
}
86+
interface TransformPxParams extends TransformBaseParams {
87+
/**
88+
* The length value
89+
* @example 16
90+
*/
91+
value: number;
92+
}
93+
interface TransformComponentParams {
94+
/**
95+
* The design component
96+
*/
97+
component: DesignComponent;
98+
}
99+
type TransformOptions = {
100+
/**
101+
* The language of the code block for syntax highlighting
102+
* @example 'scss'
103+
*/
104+
lang?: SupportedLang;
105+
/**
106+
* Transform the generated CSS code
107+
*/
108+
transform?: (params: TransformParams) => string;
109+
/**
110+
* Transform the generated CSS variable code
111+
* @example 'var(--kui-color-primary, #6699cc)' -> '$ui-color-primary'
112+
*/
113+
transformVariable?: (params: TransformVariableParams) => string;
114+
/**
115+
* Transform the pixel value to the desired unit and scale
116+
* @example 16 -> '1rem'
117+
*/
118+
transformPx?: (params: TransformPxParams) => string;
119+
/**
120+
* Transform the design component to a dev component
121+
*/
122+
transformComponent?: (params: TransformComponentParams) => DevComponent | string;
123+
};
124+
type CodeBlockOptions = (TransformOptions & {
125+
/**
126+
* The title of the code block
127+
* @example 'SCSS'
128+
*/
129+
title?: string;
130+
}) | false;
131+
type BuiltInCodeBlock = 'css' | 'js';
132+
type CodeOptions = Partial<Record<BuiltInCodeBlock, CodeBlockOptions>> & Record<string, CodeBlockOptions>;
133+
interface Plugin {
134+
name: string;
135+
code: CodeOptions;
136+
}
137+
138+
declare const _default: Plugin;
139+
140+
export { _default as default };

dist/index.d.ts

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
type ComponentPropertyValue = string | number | boolean | DesignComponent;
2+
type SupportedDesignNodeType = 'GROUP' | 'FRAME' | 'VECTOR' | 'TEXT' | 'INSTANCE';
3+
interface DesignNodeBase {
4+
name: string;
5+
type: SupportedDesignNodeType;
6+
visible: boolean;
7+
}
8+
type DesignNode = GroupNode | FrameNode | VectorNode | TextNode | DesignComponent;
9+
interface TextNode extends DesignNodeBase {
10+
type: 'TEXT';
11+
characters: string;
12+
}
13+
interface ContainerNodeBase extends DesignNodeBase {
14+
children: DesignNode[];
15+
}
16+
interface GroupNode extends ContainerNodeBase {
17+
type: 'GROUP';
18+
}
19+
interface FrameNode extends ContainerNodeBase {
20+
type: 'FRAME';
21+
}
22+
interface Variable {
23+
name: string;
24+
value: string;
25+
}
26+
interface Fill {
27+
color: string | Variable;
28+
}
29+
interface VectorNode extends DesignNodeBase {
30+
type: 'VECTOR';
31+
fills: Fill[];
32+
}
33+
interface DesignComponent<T extends object = Record<string, ComponentPropertyValue>> extends ContainerNodeBase {
34+
type: 'INSTANCE';
35+
properties: T;
36+
mainComponent?: {
37+
id: string;
38+
name: string;
39+
} | null;
40+
}
41+
interface DevComponent<T extends object = Record<string, unknown>> {
42+
name: string;
43+
props: T;
44+
children: (DevComponent | string)[];
45+
}
46+
type SupportedLang = 'text' | 'tsx' | 'jsx' | 'ts' | 'js' | 'vue' | 'html' | 'css' | 'sass' | 'scss' | 'less' | 'stylus' | 'json';
47+
interface TransformBaseParams {
48+
/**
49+
* The user preferences related to code transformation
50+
* @example { useRem: true, rootFontSize: 16 }
51+
*/
52+
options: {
53+
useRem: boolean;
54+
rootFontSize: number;
55+
};
56+
}
57+
interface TransformParams extends TransformBaseParams {
58+
/**
59+
* The generated CSS code
60+
* @example 'background-color: red; color: blue;'
61+
*/
62+
code: string;
63+
/**
64+
* The parsed CSS properties
65+
* @example { 'background-color': 'red', 'color': 'blue' }
66+
*/
67+
style: Record<string, string>;
68+
}
69+
interface TransformVariableParams extends TransformBaseParams {
70+
/**
71+
* The generated CSS variable code
72+
* @example 'var(--color-primary, #6699cc)'
73+
*/
74+
code: string;
75+
/**
76+
* The variable name
77+
* @example 'color-primary'
78+
*/
79+
name: string;
80+
/**
81+
* The variable value
82+
* @example '#6699cc'
83+
*/
84+
value?: string;
85+
}
86+
interface TransformPxParams extends TransformBaseParams {
87+
/**
88+
* The length value
89+
* @example 16
90+
*/
91+
value: number;
92+
}
93+
interface TransformComponentParams {
94+
/**
95+
* The design component
96+
*/
97+
component: DesignComponent;
98+
}
99+
type TransformOptions = {
100+
/**
101+
* The language of the code block for syntax highlighting
102+
* @example 'scss'
103+
*/
104+
lang?: SupportedLang;
105+
/**
106+
* Transform the generated CSS code
107+
*/
108+
transform?: (params: TransformParams) => string;
109+
/**
110+
* Transform the generated CSS variable code
111+
* @example 'var(--kui-color-primary, #6699cc)' -> '$ui-color-primary'
112+
*/
113+
transformVariable?: (params: TransformVariableParams) => string;
114+
/**
115+
* Transform the pixel value to the desired unit and scale
116+
* @example 16 -> '1rem'
117+
*/
118+
transformPx?: (params: TransformPxParams) => string;
119+
/**
120+
* Transform the design component to a dev component
121+
*/
122+
transformComponent?: (params: TransformComponentParams) => DevComponent | string;
123+
};
124+
type CodeBlockOptions = (TransformOptions & {
125+
/**
126+
* The title of the code block
127+
* @example 'SCSS'
128+
*/
129+
title?: string;
130+
}) | false;
131+
type BuiltInCodeBlock = 'css' | 'js';
132+
type CodeOptions = Partial<Record<BuiltInCodeBlock, CodeBlockOptions>> & Record<string, CodeBlockOptions>;
133+
interface Plugin {
134+
name: string;
135+
code: CodeOptions;
136+
}
137+
138+
declare const _default: Plugin;
139+
140+
export { _default as default };

dist/index.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
function l(e){return e}const s={name:"My Plugin",code:{css:{title:"Stylus",lang:"stylus",transform({style:e}){return Object.entries(e).map(([n,t])=>`${n} ${t}`).join(`
2+
`)}},js:!1}};export{s as default};

0 commit comments

Comments
 (0)