@styleframe/transpiler 1.0.0
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/.tsbuildinfo +1 -0
- package/CHANGELOG.md +12 -0
- package/package.json +43 -0
- package/src/constants.ts +4 -0
- package/src/consume/at-rule.test.ts +339 -0
- package/src/consume/at-rule.ts +34 -0
- package/src/consume/consume.test.ts +259 -0
- package/src/consume/consume.ts +60 -0
- package/src/consume/container.test.ts +501 -0
- package/src/consume/container.ts +73 -0
- package/src/consume/css.test.ts +184 -0
- package/src/consume/css.ts +17 -0
- package/src/consume/declarations.test.ts +210 -0
- package/src/consume/declarations.ts +17 -0
- package/src/consume/index.ts +12 -0
- package/src/consume/primitive.test.ts +52 -0
- package/src/consume/primitive.ts +16 -0
- package/src/consume/ref.test.ts +84 -0
- package/src/consume/ref.ts +22 -0
- package/src/consume/root.test.ts +353 -0
- package/src/consume/root.ts +19 -0
- package/src/consume/selector.test.ts +441 -0
- package/src/consume/selector.ts +17 -0
- package/src/consume/theme.test.ts +215 -0
- package/src/consume/theme.ts +15 -0
- package/src/consume/utility.test.ts +696 -0
- package/src/consume/utility.ts +31 -0
- package/src/consume/variable.test.ts +197 -0
- package/src/consume/variable.ts +20 -0
- package/src/defaults.ts +21 -0
- package/src/generator/genAtRuleQuery.test.ts +148 -0
- package/src/generator/genAtRuleQuery.ts +3 -0
- package/src/generator/genDeclaration.test.ts +283 -0
- package/src/generator/genDeclaration.ts +9 -0
- package/src/generator/genDeclarationsBlock.test.ts +278 -0
- package/src/generator/genDeclarationsBlock.ts +7 -0
- package/src/generator/genDeclareVariable.test.ts +323 -0
- package/src/generator/genDeclareVariable.ts +6 -0
- package/src/generator/genInlineAtRule.test.ts +351 -0
- package/src/generator/genInlineAtRule.ts +5 -0
- package/src/generator/genReferenceVariable.test.ts +392 -0
- package/src/generator/genReferenceVariable.ts +5 -0
- package/src/generator/genSafePropertyName.test.ts +489 -0
- package/src/generator/genSafePropertyName.ts +5 -0
- package/src/generator/genSafeVariableName.test.ts +358 -0
- package/src/generator/genSafeVariableName.ts +21 -0
- package/src/generator/genSelector.test.ts +357 -0
- package/src/generator/genSelector.ts +5 -0
- package/src/generator/index.ts +9 -0
- package/src/index.ts +6 -0
- package/src/transpile.test.ts +825 -0
- package/src/transpile.ts +21 -0
- package/src/types.ts +15 -0
- package/src/utils.ts +18 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig.json +7 -0
- package/vite.config.ts +5 -0
package/src/transpile.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Styleframe } from "@styleframe/core";
|
|
2
|
+
import { consume } from "./consume";
|
|
3
|
+
import type { Output, OutputFile } from "./types";
|
|
4
|
+
|
|
5
|
+
export function createFile(name: string, content: string = ""): OutputFile {
|
|
6
|
+
return {
|
|
7
|
+
name,
|
|
8
|
+
content,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function transpile(instance: Styleframe): Output {
|
|
13
|
+
const output: Output = { files: [] };
|
|
14
|
+
const options = instance.options;
|
|
15
|
+
|
|
16
|
+
const indexFile = createFile("index.css", consume(instance.root, options));
|
|
17
|
+
|
|
18
|
+
output.files.push(indexFile);
|
|
19
|
+
|
|
20
|
+
return output;
|
|
21
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { StyleframeOptions } from "@styleframe/core";
|
|
2
|
+
|
|
3
|
+
export type OutputFile = {
|
|
4
|
+
name: string;
|
|
5
|
+
content: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type Output = {
|
|
9
|
+
files: OutputFile[];
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type ConsumeFunction = (
|
|
13
|
+
instance: unknown,
|
|
14
|
+
options: StyleframeOptions,
|
|
15
|
+
) => string;
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DEFAULT_INDENT } from "./constants";
|
|
2
|
+
import { kebabCase } from "scule";
|
|
3
|
+
import type { KebabCase } from "scule";
|
|
4
|
+
|
|
5
|
+
export function addIndentToLine(line: string): string {
|
|
6
|
+
return `${DEFAULT_INDENT}${line}`;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function indentLines(lines: string): string {
|
|
10
|
+
return lines
|
|
11
|
+
.split("\n")
|
|
12
|
+
.map((line) => addIndentToLine(line))
|
|
13
|
+
.join("\n");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function toKebabCase<S extends string>(str: S): KebabCase<S> {
|
|
17
|
+
return kebabCase(str);
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
package/tsconfig.json
ADDED