@jesscss/plugin-less-compat 2.0.0-alpha.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 (111) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +139 -0
  3. package/lib/index.d.ts +9 -0
  4. package/lib/index.js +10 -0
  5. package/lib/index.js.map +1 -0
  6. package/lib/less-compat-structures.d.ts +108 -0
  7. package/lib/less-compat-structures.js +519 -0
  8. package/lib/less-compat-structures.js.map +1 -0
  9. package/lib/nodes/at-rule.d.ts +6 -0
  10. package/lib/nodes/at-rule.js +72 -0
  11. package/lib/nodes/at-rule.js.map +1 -0
  12. package/lib/nodes/attribute-selector.d.ts +6 -0
  13. package/lib/nodes/attribute-selector.js +54 -0
  14. package/lib/nodes/attribute-selector.js.map +1 -0
  15. package/lib/nodes/call.d.ts +6 -0
  16. package/lib/nodes/call.js +83 -0
  17. package/lib/nodes/call.js.map +1 -0
  18. package/lib/nodes/color.d.ts +6 -0
  19. package/lib/nodes/color.js +57 -0
  20. package/lib/nodes/color.js.map +1 -0
  21. package/lib/nodes/combinator.d.ts +6 -0
  22. package/lib/nodes/combinator.js +34 -0
  23. package/lib/nodes/combinator.js.map +1 -0
  24. package/lib/nodes/comment.d.ts +6 -0
  25. package/lib/nodes/comment.js +41 -0
  26. package/lib/nodes/comment.js.map +1 -0
  27. package/lib/nodes/condition.d.ts +6 -0
  28. package/lib/nodes/condition.js +60 -0
  29. package/lib/nodes/condition.js.map +1 -0
  30. package/lib/nodes/declaration.d.ts +6 -0
  31. package/lib/nodes/declaration.js +81 -0
  32. package/lib/nodes/declaration.js.map +1 -0
  33. package/lib/nodes/dimension.d.ts +6 -0
  34. package/lib/nodes/dimension.js +47 -0
  35. package/lib/nodes/dimension.js.map +1 -0
  36. package/lib/nodes/expression.d.ts +6 -0
  37. package/lib/nodes/expression.js +44 -0
  38. package/lib/nodes/expression.js.map +1 -0
  39. package/lib/nodes/extend.d.ts +6 -0
  40. package/lib/nodes/extend.js +57 -0
  41. package/lib/nodes/extend.js.map +1 -0
  42. package/lib/nodes/import.d.ts +6 -0
  43. package/lib/nodes/import.js +63 -0
  44. package/lib/nodes/import.js.map +1 -0
  45. package/lib/nodes/index.d.ts +45 -0
  46. package/lib/nodes/index.js +308 -0
  47. package/lib/nodes/index.js.map +1 -0
  48. package/lib/nodes/keyword.d.ts +6 -0
  49. package/lib/nodes/keyword.js +36 -0
  50. package/lib/nodes/keyword.js.map +1 -0
  51. package/lib/nodes/list.d.ts +6 -0
  52. package/lib/nodes/list.js +150 -0
  53. package/lib/nodes/list.js.map +1 -0
  54. package/lib/nodes/mixin.d.ts +6 -0
  55. package/lib/nodes/mixin.js +62 -0
  56. package/lib/nodes/mixin.js.map +1 -0
  57. package/lib/nodes/negative.d.ts +6 -0
  58. package/lib/nodes/negative.js +42 -0
  59. package/lib/nodes/negative.js.map +1 -0
  60. package/lib/nodes/operation.d.ts +6 -0
  61. package/lib/nodes/operation.js +63 -0
  62. package/lib/nodes/operation.js.map +1 -0
  63. package/lib/nodes/paren.d.ts +6 -0
  64. package/lib/nodes/paren.js +42 -0
  65. package/lib/nodes/paren.js.map +1 -0
  66. package/lib/nodes/quoted.d.ts +6 -0
  67. package/lib/nodes/quoted.js +57 -0
  68. package/lib/nodes/quoted.js.map +1 -0
  69. package/lib/nodes/reference.d.ts +9 -0
  70. package/lib/nodes/reference.js +80 -0
  71. package/lib/nodes/reference.js.map +1 -0
  72. package/lib/nodes/ruleset.d.ts +6 -0
  73. package/lib/nodes/ruleset.js +108 -0
  74. package/lib/nodes/ruleset.js.map +1 -0
  75. package/lib/nodes/selector.d.ts +8 -0
  76. package/lib/nodes/selector.js +226 -0
  77. package/lib/nodes/selector.js.map +1 -0
  78. package/lib/nodes/sequence.d.ts +9 -0
  79. package/lib/nodes/sequence.js +75 -0
  80. package/lib/nodes/sequence.js.map +1 -0
  81. package/lib/nodes/url.d.ts +6 -0
  82. package/lib/nodes/url.js +42 -0
  83. package/lib/nodes/url.js.map +1 -0
  84. package/lib/nodes/var-declaration.d.ts +6 -0
  85. package/lib/nodes/var-declaration.js +60 -0
  86. package/lib/nodes/var-declaration.js.map +1 -0
  87. package/lib/plugin-utils.d.ts +20 -0
  88. package/lib/plugin-utils.js +100 -0
  89. package/lib/plugin-utils.js.map +1 -0
  90. package/lib/plugin.d.ts +92 -0
  91. package/lib/plugin.js +1027 -0
  92. package/lib/plugin.js.map +1 -0
  93. package/lib/transform/from-less.d.ts +30 -0
  94. package/lib/transform/from-less.js +170 -0
  95. package/lib/transform/from-less.js.map +1 -0
  96. package/lib/transform/index.d.ts +7 -0
  97. package/lib/transform/index.js +8 -0
  98. package/lib/transform/index.js.map +1 -0
  99. package/lib/transform/proxy.d.ts +32 -0
  100. package/lib/transform/proxy.js +138 -0
  101. package/lib/transform/proxy.js.map +1 -0
  102. package/lib/transform/to-less.d.ts +17 -0
  103. package/lib/transform/to-less.js +128 -0
  104. package/lib/transform/to-less.js.map +1 -0
  105. package/lib/transform/type-map.d.ts +27 -0
  106. package/lib/transform/type-map.js +105 -0
  107. package/lib/transform/type-map.js.map +1 -0
  108. package/lib/types.d.ts +33 -0
  109. package/lib/types.js +5 -0
  110. package/lib/types.js.map +1 -0
  111. package/package.json +56 -0
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Type mapping utilities for converting between Jess and Less node types
3
+ */
4
+ /**
5
+ * Map Jess node types to Less node types
6
+ *
7
+ * @param jessType - The Jess node type
8
+ * @returns The corresponding Less node type
9
+ */
10
+ export declare function mapJessTypeToLessType(jessType: string): string;
11
+ /**
12
+ * Map Less node types to Jess node types
13
+ *
14
+ * @param lessType - The Less node type
15
+ * @returns The corresponding Jess node type
16
+ */
17
+ export declare function mapLessTypeToJessType(lessType: string): string;
18
+ /**
19
+ * Get Less typeIndex for a Jess node type
20
+ *
21
+ * Less.js uses typeIndex for visitor caching. This function
22
+ * maps Jess types to their corresponding Less typeIndex values.
23
+ *
24
+ * @param jessType - The Jess node type
25
+ * @returns The Less typeIndex, or undefined if not found
26
+ */
27
+ export declare function getLessTypeIndex(_jessType: string): number | undefined;
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Type mapping utilities for converting between Jess and Less node types
3
+ */
4
+ /**
5
+ * Map Jess node types to Less node types
6
+ *
7
+ * @param jessType - The Jess node type
8
+ * @returns The corresponding Less node type
9
+ */
10
+ export function mapJessTypeToLessType(jessType) {
11
+ const typeMap = {
12
+ Ruleset: 'Ruleset',
13
+ Declaration: 'Declaration',
14
+ SelectorList: 'Selector',
15
+ ComplexSelector: 'Selector',
16
+ CompoundSelector: 'Selector',
17
+ BasicSelector: 'Element', // Note: Less's Element includes combinator
18
+ Combinator: 'Combinator',
19
+ AttributeSelector: 'Attribute',
20
+ Dimension: 'Dimension',
21
+ Num: 'Dimension',
22
+ Reference: 'Variable', // Default, but can be Variable/Property/VariableCall
23
+ Mixin: 'MixinDefinition',
24
+ Call: 'Call',
25
+ Operation: 'Operation',
26
+ Expression: 'Expression',
27
+ Sequence: 'Expression',
28
+ Quoted: 'Quoted',
29
+ Url: 'URL',
30
+ Color: 'Color',
31
+ Comment: 'Comment',
32
+ AtRule: 'AtRule',
33
+ StyleImport: 'Import',
34
+ Extend: 'Extend',
35
+ Condition: 'Condition',
36
+ Paren: 'Paren',
37
+ Negative: 'Negative',
38
+ List: 'Value',
39
+ VarDeclaration: 'Assignment',
40
+ Keyword: 'Keyword'
41
+ };
42
+ return typeMap[jessType] || jessType;
43
+ }
44
+ /**
45
+ * Map Less node types to Jess node types
46
+ *
47
+ * @param lessType - The Less node type
48
+ * @returns The corresponding Jess node type
49
+ */
50
+ export function mapLessTypeToJessType(lessType) {
51
+ const typeMap = {
52
+ Ruleset: 'Ruleset',
53
+ Declaration: 'Declaration',
54
+ Selector: 'SelectorList', // Less Selector → Jess SelectorList
55
+ Element: 'BasicSelector', // Note: Less Element includes combinator
56
+ Combinator: 'Combinator',
57
+ Attribute: 'AttributeSelector',
58
+ Dimension: 'Dimension',
59
+ Variable: 'Reference',
60
+ Property: 'Reference',
61
+ VariableCall: 'Reference',
62
+ MixinDefinition: 'Mixin',
63
+ MixinCall: 'Call',
64
+ Call: 'Call',
65
+ Operation: 'Operation',
66
+ Expression: 'Expression',
67
+ Quoted: 'Quoted',
68
+ URL: 'Url',
69
+ Color: 'Color',
70
+ Comment: 'Comment',
71
+ AtRule: 'AtRule',
72
+ // Less.js v2 used "Directive" - map to AtRule for compatibility
73
+ Directive: 'AtRule',
74
+ // Less.js v2 used "Rule" - map to Declaration for compatibility
75
+ Rule: 'Declaration',
76
+ Import: 'StyleImport',
77
+ Extend: 'Extend',
78
+ Condition: 'Condition',
79
+ Paren: 'Paren',
80
+ Negative: 'Negative',
81
+ Value: 'List',
82
+ Assignment: 'VarDeclaration',
83
+ Keyword: 'Keyword'
84
+ };
85
+ return typeMap[lessType] || lessType;
86
+ }
87
+ /**
88
+ * Get Less typeIndex for a Jess node type
89
+ *
90
+ * Less.js uses typeIndex for visitor caching. This function
91
+ * maps Jess types to their corresponding Less typeIndex values.
92
+ *
93
+ * @param jessType - The Jess node type
94
+ * @returns The Less typeIndex, or undefined if not found
95
+ */
96
+ export function getLessTypeIndex(_jessType) {
97
+ // Less.js assigns typeIndex dynamically, so we'll need to
98
+ // either:
99
+ // 1. Import Less's tree module and access typeIndex
100
+ // 2. Maintain our own mapping
101
+ // 3. Set typeIndex dynamically when creating proxies
102
+ // For now, return undefined - will be set during proxy creation
103
+ return undefined;
104
+ }
105
+ //# sourceMappingURL=type-map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-map.js","sourceRoot":"","sources":["../../src/transform/type-map.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAgB;IACpD,MAAM,OAAO,GAA2B;QACtC,OAAO,EAAE,SAAS;QAClB,WAAW,EAAE,aAAa;QAC1B,YAAY,EAAE,UAAU;QACxB,eAAe,EAAE,UAAU;QAC3B,g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G,EAAE,KAAK;QACV,KAAK,EAAE,OAAO;QACd,OAAO,EAAE,SAAS;QAClB,MAAM,EAAE,QAAQ;QAChB,gEAAgE;QAChE,SAAS,EAAE,QAAQ;QACnB,gEAAgE;QAChE,IAAI,EAAE,aAAa;QACnB,MAAM,EAAE,aAAa;QACrB,MAAM,EAAE,QAAQ;QAChB,SAAS,EAAE,WAAW;QACtB,KAAK,EAAE,OAAO;QACd,QAAQ,EAAE,UAAU;QACpB,KAAK,EAAE,MAAM;QACb,UAAU,EAAE,gBAAgB;QAC5B,OAAO,EAAE,SAAS;KACnB,CAAC;IAEF,OAAO,OAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC;AACvC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAAiB;IAChD,0DAA0D;IAC1D,UAAU;IACV,oDAAoD;IACpD,8BAA8B;IAC9B,qDAAqD;IAErD,gEAAgE;IAChE,OAAO,SAAS,CAAC;AACnB,CAAC"}
package/lib/types.d.ts ADDED
@@ -0,0 +1,33 @@
1
+ /**
2
+ * TypeScript type definitions for Less.js compatibility
3
+ */
4
+ export type LessNode = any;
5
+ /**
6
+ * @deprecated Less.js Visitor API - This is a compatibility type for Less.js visitors.
7
+ * Use Jess's native Visitor interface instead when possible.
8
+ */
9
+ export type LessVisitor = any;
10
+ export type LessRuleset = any;
11
+ export type LessSelector = any;
12
+ export type LessElement = any;
13
+ export type LessDeclaration = any;
14
+ export type LessVariable = any;
15
+ export type LessProperty = any;
16
+ export type LessVariableCall = any;
17
+ export type LessMixinDefinition = any;
18
+ export type LessMixinCall = any;
19
+ export type LessDimension = any;
20
+ export type LessColor = any;
21
+ export type LessOperation = any;
22
+ export type LessExpression = any;
23
+ export type LessQuoted = any;
24
+ export type LessURL = any;
25
+ export type LessComment = any;
26
+ export type LessAtRule = any;
27
+ export type LessImport = any;
28
+ export type LessExtend = any;
29
+ export type LessCondition = any;
30
+ export type LessParen = any;
31
+ export type LessNegative = any;
32
+ export type LessValue = any;
33
+ export type LessAssignment = any;
package/lib/types.js ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * TypeScript type definitions for Less.js compatibility
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@jesscss/plugin-less-compat",
3
+ "publishConfig": {
4
+ "access": "public"
5
+ },
6
+ "description": "Less.js compatibility layer for Jess - enables Less plugins and visitors to work with Jess AST",
7
+ "version": "2.0.0-alpha.1",
8
+ "type": "module",
9
+ "main": "lib/index.js",
10
+ "types": "lib/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "import": "./lib/index.js",
14
+ "types": "./lib/index.d.ts",
15
+ "source": "./src/index.ts"
16
+ },
17
+ "./transform": {
18
+ "import": "./lib/transform/index.js",
19
+ "types": "./lib/transform/index.d.ts",
20
+ "source": "./src/transform/index.ts"
21
+ },
22
+ "./less-compat-structures": {
23
+ "import": "./lib/less-compat-structures.js",
24
+ "types": "./lib/less-compat-structures.d.ts",
25
+ "source": "./src/less-compat-structures.ts"
26
+ },
27
+ "./package.json": "./package.json"
28
+ },
29
+ "files": [
30
+ "lib"
31
+ ],
32
+ "dependencies": {
33
+ "@jesscss/core": "2.0.0-alpha.1",
34
+ "@jesscss/less-parser": "2.0.0-alpha.1",
35
+ "@jesscss/plugin-node-modules": "2.0.0-alpha.1"
36
+ },
37
+ "devDependencies": {
38
+ "less-plugin-autoprefix": "^2.0.0",
39
+ "less-plugin-clean-css": "^1.6.0",
40
+ "less-plugin-dls": "^1.5.0"
41
+ },
42
+ "author": "Matthew Dean <matthew-dean@users.noreply.github.com>",
43
+ "license": "MIT",
44
+ "bugs": {
45
+ "url": "https://github.com/jesscss/jess/issues"
46
+ },
47
+ "homepage": "https://github.com/jesscss/jess#readme",
48
+ "scripts": {
49
+ "ci": "pnpm build && pnpm test",
50
+ "build": "pnpm compile",
51
+ "compile": "tsc -b tsconfig.build.json",
52
+ "test": "cross-env TEST=true vitest --run",
53
+ "lint:fix": "eslint --fix '**/*.{js,ts}'",
54
+ "lint": "eslint '**/*.{js,ts}'"
55
+ }
56
+ }