@f12io/maple 2.0.1

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.
Files changed (63) hide show
  1. package/LICENSE +33 -0
  2. package/README.md +187 -0
  3. package/dist/keyframes.css +445 -0
  4. package/dist/maple.js +2 -0
  5. package/dist/module/index.cjs +2 -0
  6. package/dist/module/index.js +2 -0
  7. package/dist/module/types/src/core/aliases.d.cts +3 -0
  8. package/dist/module/types/src/core/aliases.d.ts +3 -0
  9. package/dist/module/types/src/core/bootstrap.d.cts +1 -0
  10. package/dist/module/types/src/core/bootstrap.d.ts +1 -0
  11. package/dist/module/types/src/core/builder.d.cts +2 -0
  12. package/dist/module/types/src/core/builder.d.ts +2 -0
  13. package/dist/module/types/src/core/constants/caches.d.cts +7 -0
  14. package/dist/module/types/src/core/constants/caches.d.ts +7 -0
  15. package/dist/module/types/src/core/constants/chars.d.cts +33 -0
  16. package/dist/module/types/src/core/constants/chars.d.ts +33 -0
  17. package/dist/module/types/src/core/constants/config.d.cts +17 -0
  18. package/dist/module/types/src/core/constants/config.d.ts +17 -0
  19. package/dist/module/types/src/core/constants/dictionaries.d.cts +16 -0
  20. package/dist/module/types/src/core/constants/dictionaries.d.ts +16 -0
  21. package/dist/module/types/src/core/constants/precalculated-prop-types.d.cts +6 -0
  22. package/dist/module/types/src/core/constants/precalculated-prop-types.d.ts +6 -0
  23. package/dist/module/types/src/core/constants/regex.d.cts +18 -0
  24. package/dist/module/types/src/core/constants/regex.d.ts +18 -0
  25. package/dist/module/types/src/core/constants/units.d.cts +14 -0
  26. package/dist/module/types/src/core/constants/units.d.ts +14 -0
  27. package/dist/module/types/src/core/generator.d.cts +5 -0
  28. package/dist/module/types/src/core/generator.d.ts +5 -0
  29. package/dist/module/types/src/core/helpers/cache.helper.d.cts +1 -0
  30. package/dist/module/types/src/core/helpers/cache.helper.d.ts +1 -0
  31. package/dist/module/types/src/core/helpers/escape-class-polyfill.d.cts +1 -0
  32. package/dist/module/types/src/core/helpers/escape-class-polyfill.d.ts +1 -0
  33. package/dist/module/types/src/core/helpers/escape-class.d.cts +1 -0
  34. package/dist/module/types/src/core/helpers/escape-class.d.ts +1 -0
  35. package/dist/module/types/src/core/helpers/merge.helper.d.cts +1 -0
  36. package/dist/module/types/src/core/helpers/merge.helper.d.ts +1 -0
  37. package/dist/module/types/src/core/helpers/property.helper.d.cts +11 -0
  38. package/dist/module/types/src/core/helpers/property.helper.d.ts +11 -0
  39. package/dist/module/types/src/core/helpers/string.helper.d.cts +7 -0
  40. package/dist/module/types/src/core/helpers/string.helper.d.ts +7 -0
  41. package/dist/module/types/src/core/observer.d.cts +1 -0
  42. package/dist/module/types/src/core/observer.d.ts +1 -0
  43. package/dist/module/types/src/core/parser-class.d.cts +3 -0
  44. package/dist/module/types/src/core/parser-class.d.ts +3 -0
  45. package/dist/module/types/src/core/parser-media-query.d.cts +2 -0
  46. package/dist/module/types/src/core/parser-media-query.d.ts +2 -0
  47. package/dist/module/types/src/core/serializer.d.cts +8 -0
  48. package/dist/module/types/src/core/serializer.d.ts +8 -0
  49. package/dist/module/types/src/core/stylesheet.d.cts +4 -0
  50. package/dist/module/types/src/core/stylesheet.d.ts +4 -0
  51. package/dist/module/types/src/core/types.d.cts +65 -0
  52. package/dist/module/types/src/core/types.d.ts +65 -0
  53. package/dist/module/types/src/generated/precalculated-prop-abbreviations.d.cts +1 -0
  54. package/dist/module/types/src/generated/precalculated-prop-abbreviations.d.ts +1 -0
  55. package/dist/module/types/src/generated/precalculated-prop-types.d.cts +1 -0
  56. package/dist/module/types/src/generated/precalculated-prop-types.d.ts +1 -0
  57. package/dist/module/types/src/index.d.cts +11 -0
  58. package/dist/module/types/src/index.d.ts +11 -0
  59. package/dist/module/types/src/runtime.d.cts +1 -0
  60. package/dist/module/types/src/runtime.d.ts +1 -0
  61. package/dist/module/types/tests/helpers/convert.helper.d.cts +2 -0
  62. package/dist/module/types/tests/helpers/convert.helper.d.ts +2 -0
  63. package/package.json +59 -0
@@ -0,0 +1,14 @@
1
+ export declare const ANGLE_UNITS: string[];
2
+ export declare const TIME_UNITS: string[];
3
+ export declare const ABS_UNITS: string[];
4
+ export declare const REL_UNITS: string[];
5
+ export declare const ONE_UNITS: string[];
6
+ export declare const COVER_UNITS: string[];
7
+ export declare const DEFAULT_SPACE_UNIT = "rem";
8
+ export declare const DEFAULT_TIME_UNIT = "ms";
9
+ export declare const DEFAULT_ANGLE_UNIT = "deg";
10
+ export declare const DEFAULT_COLOR_VALUE = "#000000";
11
+ export declare const DEFAULT_SPACE_VALUE = "1rem";
12
+ export declare const DEFAULT_TIME_VALUE = "1ms";
13
+ export declare const DEFAULT_ANGLE_VALUE = "1deg";
14
+ export declare const ALL_UNITS: string[];
@@ -0,0 +1,14 @@
1
+ export declare const ANGLE_UNITS: string[];
2
+ export declare const TIME_UNITS: string[];
3
+ export declare const ABS_UNITS: string[];
4
+ export declare const REL_UNITS: string[];
5
+ export declare const ONE_UNITS: string[];
6
+ export declare const COVER_UNITS: string[];
7
+ export declare const DEFAULT_SPACE_UNIT = "rem";
8
+ export declare const DEFAULT_TIME_UNIT = "ms";
9
+ export declare const DEFAULT_ANGLE_UNIT = "deg";
10
+ export declare const DEFAULT_COLOR_VALUE = "#000000";
11
+ export declare const DEFAULT_SPACE_VALUE = "1rem";
12
+ export declare const DEFAULT_TIME_VALUE = "1ms";
13
+ export declare const DEFAULT_ANGLE_VALUE = "1deg";
14
+ export declare const ALL_UNITS: string[];
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Processes an element's classes, removing earlier conflicting classes.
3
+ * Uses reverse loop: later classes always win.
4
+ */
5
+ export declare function processClassList(element: Element): void;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Processes an element's classes, removing earlier conflicting classes.
3
+ * Uses reverse loop: later classes always win.
4
+ */
5
+ export declare function processClassList(element: Element): void;
@@ -0,0 +1 @@
1
+ export declare function setCacheItem<T>(cache: Map<string, T>, cacheKey: string, value: T): void;
@@ -0,0 +1 @@
1
+ export declare function setCacheItem<T>(cache: Map<string, T>, cacheKey: string, value: T): void;
@@ -0,0 +1 @@
1
+ export declare function escapeClass(str: string | number | undefined | null): string;
@@ -0,0 +1 @@
1
+ export declare function escapeClass(str: string | number | undefined | null): string;
@@ -0,0 +1 @@
1
+ export declare function escapeClass(str: string): string;
@@ -0,0 +1 @@
1
+ export declare function escapeClass(str: string): string;
@@ -0,0 +1 @@
1
+ export declare function isMergeException(key: string): boolean;
@@ -0,0 +1 @@
1
+ export declare function isMergeException(key: string): boolean;
@@ -0,0 +1,11 @@
1
+ export declare function resolveType(propKeyKebab: string, propKeyCamel: string): number;
2
+ export declare function isKnownProperty(propKeyKebab: string): 1 | 0;
3
+ export declare function isKnownNumberValue(val: string): 1 | 0;
4
+ export declare function isKnownAngleValue(val: string): 1 | 0;
5
+ export declare function isKnownColorValue(val: string): boolean;
6
+ export declare function isReservedKeyword(val: string): boolean;
7
+ export declare function isGradientDirection(value: string): boolean;
8
+ export declare function isKnownTimingFunction(val: string): boolean;
9
+ export declare function isKnownAnimationDirection(val: string): boolean;
10
+ export declare function isKnownAnimationFillMode(val: string): boolean;
11
+ export declare function isKnownAnimationPlayState(val: string): boolean;
@@ -0,0 +1,11 @@
1
+ export declare function resolveType(propKeyKebab: string, propKeyCamel: string): number;
2
+ export declare function isKnownProperty(propKeyKebab: string): 1 | 0;
3
+ export declare function isKnownNumberValue(val: string): 1 | 0;
4
+ export declare function isKnownAngleValue(val: string): 1 | 0;
5
+ export declare function isKnownColorValue(val: string): boolean;
6
+ export declare function isReservedKeyword(val: string): boolean;
7
+ export declare function isGradientDirection(value: string): boolean;
8
+ export declare function isKnownTimingFunction(val: string): boolean;
9
+ export declare function isKnownAnimationDirection(val: string): boolean;
10
+ export declare function isKnownAnimationFillMode(val: string): boolean;
11
+ export declare function isKnownAnimationPlayState(val: string): boolean;
@@ -0,0 +1,7 @@
1
+ export declare function split(source: string, separator: string): Array<string>;
2
+ export declare function toKebabCase(str: string | undefined): string;
3
+ export declare function toCamelCase(str: string | undefined): string;
4
+ export declare function escapeVariable(str: string): string;
5
+ export declare function startsWithNegative(value: string): 1 | 0;
6
+ export declare function removeBrackets(value: string): string;
7
+ export declare function splitAtFirstOccurrence(str: string, char: string): Array<string>;
@@ -0,0 +1,7 @@
1
+ export declare function split(source: string, separator: string): Array<string>;
2
+ export declare function toKebabCase(str: string | undefined): string;
3
+ export declare function toCamelCase(str: string | undefined): string;
4
+ export declare function escapeVariable(str: string): string;
5
+ export declare function startsWithNegative(value: string): 1 | 0;
6
+ export declare function removeBrackets(value: string): string;
7
+ export declare function splitAtFirstOccurrence(str: string, char: string): Array<string>;
@@ -0,0 +1 @@
1
+ export declare function startObserver(): (() => void) | undefined;
@@ -0,0 +1 @@
1
+ export declare function startObserver(): (() => void) | undefined;
@@ -0,0 +1,3 @@
1
+ import { ParsedClass, ParsedSelector } from './types';
2
+ export declare function parseClass(srcClass: string): ParsedClass;
3
+ export declare function parseSelectors(contextRaw: string): ParsedSelector | undefined;
@@ -0,0 +1,3 @@
1
+ import { ParsedClass, ParsedSelector } from './types';
2
+ export declare function parseClass(srcClass: string): ParsedClass;
3
+ export declare function parseSelectors(contextRaw: string): ParsedSelector | undefined;
@@ -0,0 +1,2 @@
1
+ import { ParsedClass, ParsedMediaQuery } from './types';
2
+ export declare function parseMediaQuery({ mediaQuery, propKeyKebab, propVal, }: ParsedClass): ParsedMediaQuery | undefined;
@@ -0,0 +1,2 @@
1
+ import { ParsedClass, ParsedMediaQuery } from './types';
2
+ export declare function parseMediaQuery({ mediaQuery, propKeyKebab, propVal, }: ParsedClass): ParsedMediaQuery | undefined;
@@ -0,0 +1,8 @@
1
+ import { Modifiers, ParsedClass, ValueModifiers } from './types';
2
+ export declare const TYPE_MODIFIERS: Modifiers;
3
+ export declare const VALUE_MODIFIERS: ValueModifiers;
4
+ export declare const PART_MODIFIERS: ValueModifiers;
5
+ export declare function applyModifier(parsed: ParsedClass): string | undefined;
6
+ export declare function serializeSelector(selector: string): string;
7
+ export declare function serializeProp(propKeyKebab: string, value: string, isImportant: 1 | 0): string;
8
+ export declare function serializeValue(value: string): string;
@@ -0,0 +1,8 @@
1
+ import { Modifiers, ParsedClass, ValueModifiers } from './types';
2
+ export declare const TYPE_MODIFIERS: Modifiers;
3
+ export declare const VALUE_MODIFIERS: ValueModifiers;
4
+ export declare const PART_MODIFIERS: ValueModifiers;
5
+ export declare function applyModifier(parsed: ParsedClass): string | undefined;
6
+ export declare function serializeSelector(selector: string): string;
7
+ export declare function serializeProp(propKeyKebab: string, value: string, isImportant: 1 | 0): string;
8
+ export declare function serializeValue(value: string): string;
@@ -0,0 +1,4 @@
1
+ import { RuleData } from './types';
2
+ export declare function flush(): void;
3
+ export declare function insert(rule: RuleData | undefined): void;
4
+ export declare function insertRefVar(key: string, val: string, type: 'number' | 'color' | 'custom'): void;
@@ -0,0 +1,4 @@
1
+ import { RuleData } from './types';
2
+ export declare function flush(): void;
3
+ export declare function insert(rule: RuleData | undefined): void;
4
+ export declare function insertRefVar(key: string, val: string, type: 'number' | 'color' | 'custom'): void;
@@ -0,0 +1,65 @@
1
+ export type Modifiers = Record<string, undefined | ((parsed: ParsedClass) => string | undefined)>;
2
+ export type ValueModifiers = Record<string, undefined | ((parsed: ParsedClass, valueItem: string, index: number, items: Array<string>) => string | undefined)>;
3
+ export type ModifierType = 'custom' | 'predefined';
4
+ export type BucketType = 'base' | 'supports' | 'mnw' | 'mxw' | 'mnh' | 'mxh' | 'orientation' | 'style' | 'scroll' | 'light' | 'dark' | 'prefers' | 'static';
5
+ export interface Bucket {
6
+ key: string;
7
+ type: BucketType;
8
+ val: number;
9
+ rule?: CSSGroupingRule;
10
+ }
11
+ export type MediaQueryBucketParams = [
12
+ bucketType: BucketType,
13
+ bucketKey: string,
14
+ bucketVal: string,
15
+ bucketQuery: string,
16
+ rootSelector?: string,
17
+ overrideRootSelector?: string
18
+ ];
19
+ export interface ParsedMediaQuery {
20
+ bucketKey: string;
21
+ bucketQuery: string;
22
+ bucketType: BucketType;
23
+ bucketVal: string;
24
+ prefix: string;
25
+ suffix: string;
26
+ rootSelector: string;
27
+ overrideRootSelector: string;
28
+ }
29
+ export interface ParsedSelector {
30
+ mediaQuery?: string;
31
+ parentSel?: string;
32
+ selfSel?: string;
33
+ childSel?: string;
34
+ isMultiSelector?: boolean;
35
+ }
36
+ export interface ParsedClass {
37
+ srcClass: string;
38
+ srcSel: string;
39
+ isImportant: 1 | 0;
40
+ isUtilNegative: 1 | 0;
41
+ isNoRef: 1 | 0;
42
+ isDynamic: 1 | 0;
43
+ mediaQuery?: string;
44
+ parentSel?: string;
45
+ selfSel?: string;
46
+ childSel?: string;
47
+ isMultiSelector?: boolean;
48
+ utilKey: string;
49
+ utilVal: string;
50
+ utilOp: '-' | '=';
51
+ propType: number;
52
+ propVal: string;
53
+ propKeyCamel: string;
54
+ propKeyKebab: string;
55
+ validVarVal: string;
56
+ conflictKey?: string;
57
+ varCat?: string;
58
+ }
59
+ export interface RuleData {
60
+ content: string;
61
+ isAlias?: boolean;
62
+ overrideRule?: RuleData;
63
+ parsedMediaQuery: ParsedMediaQuery | undefined;
64
+ parsed: ParsedClass;
65
+ }
@@ -0,0 +1,65 @@
1
+ export type Modifiers = Record<string, undefined | ((parsed: ParsedClass) => string | undefined)>;
2
+ export type ValueModifiers = Record<string, undefined | ((parsed: ParsedClass, valueItem: string, index: number, items: Array<string>) => string | undefined)>;
3
+ export type ModifierType = 'custom' | 'predefined';
4
+ export type BucketType = 'base' | 'supports' | 'mnw' | 'mxw' | 'mnh' | 'mxh' | 'orientation' | 'style' | 'scroll' | 'light' | 'dark' | 'prefers' | 'static';
5
+ export interface Bucket {
6
+ key: string;
7
+ type: BucketType;
8
+ val: number;
9
+ rule?: CSSGroupingRule;
10
+ }
11
+ export type MediaQueryBucketParams = [
12
+ bucketType: BucketType,
13
+ bucketKey: string,
14
+ bucketVal: string,
15
+ bucketQuery: string,
16
+ rootSelector?: string,
17
+ overrideRootSelector?: string
18
+ ];
19
+ export interface ParsedMediaQuery {
20
+ bucketKey: string;
21
+ bucketQuery: string;
22
+ bucketType: BucketType;
23
+ bucketVal: string;
24
+ prefix: string;
25
+ suffix: string;
26
+ rootSelector: string;
27
+ overrideRootSelector: string;
28
+ }
29
+ export interface ParsedSelector {
30
+ mediaQuery?: string;
31
+ parentSel?: string;
32
+ selfSel?: string;
33
+ childSel?: string;
34
+ isMultiSelector?: boolean;
35
+ }
36
+ export interface ParsedClass {
37
+ srcClass: string;
38
+ srcSel: string;
39
+ isImportant: 1 | 0;
40
+ isUtilNegative: 1 | 0;
41
+ isNoRef: 1 | 0;
42
+ isDynamic: 1 | 0;
43
+ mediaQuery?: string;
44
+ parentSel?: string;
45
+ selfSel?: string;
46
+ childSel?: string;
47
+ isMultiSelector?: boolean;
48
+ utilKey: string;
49
+ utilVal: string;
50
+ utilOp: '-' | '=';
51
+ propType: number;
52
+ propVal: string;
53
+ propKeyCamel: string;
54
+ propKeyKebab: string;
55
+ validVarVal: string;
56
+ conflictKey?: string;
57
+ varCat?: string;
58
+ }
59
+ export interface RuleData {
60
+ content: string;
61
+ isAlias?: boolean;
62
+ overrideRule?: RuleData;
63
+ parsedMediaQuery: ParsedMediaQuery | undefined;
64
+ parsed: ParsedClass;
65
+ }
@@ -0,0 +1 @@
1
+ export declare const PRECALCULATED_PROP_ABBREVIATIONS: Record<string, string>;
@@ -0,0 +1 @@
1
+ export declare const PRECALCULATED_PROP_ABBREVIATIONS: Record<string, string>;
@@ -0,0 +1 @@
1
+ export declare const PRECALCULATED_PROP_TYPES: Record<string, number>;
@@ -0,0 +1 @@
1
+ export declare const PRECALCULATED_PROP_TYPES: Record<string, number>;
@@ -0,0 +1,11 @@
1
+ export { convert } from '../tests/helpers/convert.helper';
2
+ export { startRuntime } from './core/bootstrap';
3
+ export { buildRule } from './core/builder';
4
+ export * from './core/constants/config';
5
+ export * from './core/constants/dictionaries';
6
+ export * from './core/constants/regex';
7
+ export * from './core/constants/units';
8
+ export { parseClass } from './core/parser-class';
9
+ export * from './core/types';
10
+ export { PRECALCULATED_PROP_ABBREVIATIONS } from './generated/precalculated-prop-abbreviations';
11
+ export { PRECALCULATED_PROP_TYPES } from './generated/precalculated-prop-types';
@@ -0,0 +1,11 @@
1
+ export { convert } from '../tests/helpers/convert.helper';
2
+ export { startRuntime } from './core/bootstrap';
3
+ export { buildRule } from './core/builder';
4
+ export * from './core/constants/config';
5
+ export * from './core/constants/dictionaries';
6
+ export * from './core/constants/regex';
7
+ export * from './core/constants/units';
8
+ export { parseClass } from './core/parser-class';
9
+ export * from './core/types';
10
+ export { PRECALCULATED_PROP_ABBREVIATIONS } from './generated/precalculated-prop-abbreviations';
11
+ export { PRECALCULATED_PROP_TYPES } from './generated/precalculated-prop-types';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export declare function convert(srcClass: string, isRoot?: boolean): string | undefined;
2
+ export declare function convertWithRefs(srcClass: string, isRoot?: boolean): string | undefined;
@@ -0,0 +1,2 @@
1
+ export declare function convert(srcClass: string, isRoot?: boolean): string | undefined;
2
+ export declare function convertWithRefs(srcClass: string, isRoot?: boolean): string | undefined;
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@f12io/maple",
3
+ "version": "2.0.1",
4
+ "private": false,
5
+ "type": "module",
6
+ "main": "./dist/module/index.cjs",
7
+ "module": "./dist/module/index.js",
8
+ "types": "./dist/module/types/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": {
12
+ "import": "./dist/module/types/index.d.ts",
13
+ "require": "./dist/module/types/index.d.cts"
14
+ },
15
+ "import": "./dist/module/index.js",
16
+ "require": "./dist/module/index.cjs"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "sideEffects": false,
23
+ "scripts": {
24
+ "dev": "concurrently \"npm run build:runtime -- --watch\" \"vite serve examples --host\"",
25
+ "clean": "rimraf dist",
26
+ "build:module": "cross-env BUILD_TYPE=lib vite build",
27
+ "build:runtime": "cross-env BUILD_TYPE=runtime vite build",
28
+ "build:types": "tsc -p tsconfig.build.json && tsx scripts/copy-dts.ts",
29
+ "build": "npm run clean && npm run build:module && npm run build:runtime && npm run build:types",
30
+ "preview": "vite preview",
31
+ "test": "vitest run --browser",
32
+ "test:watch": "vitest --browser",
33
+ "lint": "eslint .",
34
+ "prettier:fix": "prettier --write . --ignore-path .gitignore",
35
+ "preversion": "tsx scripts/preversion-check.ts && npm run lint && npm run test && npm run build",
36
+ "release": "tsx scripts/release.ts"
37
+ },
38
+ "devDependencies": {
39
+ "@eslint/js": "^9.39.2",
40
+ "@types/node": "^25.0.3",
41
+ "@vitest/browser-playwright": "^4.0.16",
42
+ "concurrently": "^9.2.1",
43
+ "cross-env": "^10.1.0",
44
+ "eslint": "^10.0.0",
45
+ "eslint-config-prettier": "^10.1.8",
46
+ "globals": "^16.5.0",
47
+ "playwright": "^1.57.0",
48
+ "prettier": "^3.7.4",
49
+ "rimraf": "^6.1.2",
50
+ "terser": "^5.46.0",
51
+ "tslib": "^2.8.1",
52
+ "tsx": "4.21.0",
53
+ "typescript": "^5.9.3",
54
+ "typescript-eslint": "^8.56.0",
55
+ "vite": "^7.3.3",
56
+ "vite-tsconfig-paths": "^6.0.3",
57
+ "vitest": "^4.0.16"
58
+ }
59
+ }